本文整理汇总了Golang中github.com/ubuntu-core/snappy/snap.Info.DataDir方法的典型用法代码示例。如果您正苦于以下问题:Golang Info.DataDir方法的具体用法?Golang Info.DataDir怎么用?Golang Info.DataDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ubuntu-core/snappy/snap.Info
的用法示例。
在下文中一共展示了Info.DataDir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UpdateCurrentSymlink
// XXX: would really like not to expose this but used in daemon tests atm
func UpdateCurrentSymlink(info *snap.Info, inter interacter) error {
mountDir := info.MountDir()
currentActiveSymlink := filepath.Join(mountDir, "..", "current")
if err := os.Remove(currentActiveSymlink); err != nil && !os.IsNotExist(err) {
logger.Noticef("Failed to remove %q: %v", currentActiveSymlink, err)
}
dataDir := info.DataDir()
dbase := filepath.Dir(dataDir)
currentDataSymlink := filepath.Join(dbase, "current")
if err := os.Remove(currentDataSymlink); err != nil && !os.IsNotExist(err) {
logger.Noticef("Failed to remove %q: %v", currentDataSymlink, err)
}
// symlink is relative to parent dir
if err := os.Symlink(filepath.Base(mountDir), currentActiveSymlink); err != nil {
return err
}
if err := os.MkdirAll(info.DataDir(), 0755); err != nil {
return err
}
// FIXME: create {Os,Kernel}Snap type instead of adding special
// cases here
if err := setNextBoot(info); err != nil {
return err
}
return os.Symlink(filepath.Base(dataDir), currentDataSymlink)
}
示例2: CopyData
func CopyData(newSnap, oldSnap *snap.Info, flags InstallFlags, meter progress.Meter) error {
dataDir := newSnap.DataDir()
// deal with the old data or
// otherwise just create a empty data dir
if oldSnap == nil {
return os.MkdirAll(dataDir, 0755)
}
return copySnapData(oldSnap, newSnap)
}
示例3: copySnapData
// Copy all data for oldSnap to newSnap
// (but never overwrite)
func copySnapData(oldSnap, newSnap *snap.Info) (err error) {
oldDataDirs, err := snapDataDirs(oldSnap)
if err != nil {
return err
}
newSuffix := filepath.Base(newSnap.DataDir())
for _, oldDir := range oldDataDirs {
// replace the trailing "../$old-suffix" with the "../$new-suffix"
newDir := filepath.Join(filepath.Dir(oldDir), newSuffix)
if err := copySnapDataDirectory(oldDir, newDir); err != nil {
return err
}
}
return nil
}
示例4: snapDataDirs
// snapDataDirs returns the list of data directories for the given snap version
func snapDataDirs(snap *snap.Info) ([]string, error) {
// collect the directories, homes first
found, err := filepath.Glob(snap.DataHomeDir())
if err != nil {
return nil, err
}
// then system data
found = append(found, snap.DataDir())
return found, nil
}