当前位置: 首页>>代码示例>>Golang>>正文


Golang Info.CommonDataDir方法代码示例

本文整理汇总了Golang中github.com/snapcore/snapd/snap.Info.CommonDataDir方法的典型用法代码示例。如果您正苦于以下问题:Golang Info.CommonDataDir方法的具体用法?Golang Info.CommonDataDir怎么用?Golang Info.CommonDataDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/snapcore/snapd/snap.Info的用法示例。


在下文中一共展示了Info.CommonDataDir方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: basicEnv

// basicEnv returns the app-level environment variables for a snap.
// Despite this being a bit snap-specific, this is in helpers.go because it's
// used by so many other modules, we run into circular dependencies if it's
// somewhere more reasonable like the snappy module.
func basicEnv(info *snap.Info) map[string]string {
	return map[string]string{
		"SNAP":              info.MountDir(),
		"SNAP_COMMON":       info.CommonDataDir(),
		"SNAP_DATA":         info.DataDir(),
		"SNAP_NAME":         info.Name(),
		"SNAP_VERSION":      info.Version,
		"SNAP_REVISION":     info.Revision.String(),
		"SNAP_ARCH":         arch.UbuntuArchitecture(),
		"SNAP_LIBRARY_PATH": "/var/lib/snapd/lib/gl:",
		"SNAP_REEXEC":       os.Getenv("SNAP_REEXEC"),
	}
}
开发者ID:pedronis,项目名称:snappy,代码行数:17,代码来源:snapenv.go

示例2: resolveSpecialVariable

// resolveSpecialVariable resolves one of the three $SNAP* variables at the
// beginning of a given path.  The variables are $SNAP, $SNAP_DATA and
// $SNAP_COMMON. If there are no variables then $SNAP is implicitly assumed
// (this is the behavior that was used before the variables were supporter).
func resolveSpecialVariable(path string, snapInfo *snap.Info) string {
	if strings.HasPrefix(path, "$SNAP/") || path == "$SNAP" {
		return strings.Replace(path, "$SNAP", snapInfo.MountDir(), 1)
	}
	if strings.HasPrefix(path, "$SNAP_DATA/") || path == "$SNAP_DATA" {
		return strings.Replace(path, "$SNAP_DATA", snapInfo.DataDir(), 1)
	}
	if strings.HasPrefix(path, "$SNAP_COMMON/") || path == "$SNAP_COMMON" {
		return strings.Replace(path, "$SNAP_COMMON", snapInfo.CommonDataDir(), 1)
	}
	// NOTE: assume $SNAP by default if nothing else is provided, for compatibility
	return filepath.Join(snapInfo.MountDir(), path)
}
开发者ID:elopio,项目名称:snappy,代码行数:17,代码来源:content.go

示例3: CopySnapData

// CopySnapData makes a copy of oldSnap data for newSnap in its data directories.
func (b Backend) CopySnapData(newSnap, oldSnap *snap.Info, meter progress.Meter) error {
	// deal with the old data or
	// otherwise just create a empty data dir

	// Make sure the common data directory exists, even if this isn't a new
	// install.
	if err := os.MkdirAll(newSnap.CommonDataDir(), 0755); err != nil {
		return err
	}

	if oldSnap == nil {
		return os.MkdirAll(newSnap.DataDir(), 0755)
	}

	return copySnapData(oldSnap, newSnap)
}
开发者ID:niemeyer,项目名称:snapd,代码行数:17,代码来源:copydata.go

示例4: snapCommonDataDirs

// snapCommonDataDirs returns the list of data directories common between versions of the given snap
func snapCommonDataDirs(snap *snap.Info) ([]string, error) {
	// collect the directories, homes first
	found, err := filepath.Glob(snap.CommonDataHomeDir())
	if err != nil {
		return nil, err
	}
	// then system data
	found = append(found, snap.CommonDataDir())

	return found, nil
}
开发者ID:niemeyer,项目名称:snapd,代码行数:12,代码来源:snapdata.go

示例5: snapCommonDataDirs

// snapCommonDataDirs returns the list of data directories common between versions of the given snap
func snapCommonDataDirs(snap *snap.Info) ([]string, error) {
	// collect the directories, homes first
	found, err := filepath.Glob(snap.CommonDataHomeDir())
	if err != nil {
		return nil, err
	}

	// then XDG_RUNTIME_DIRs for the users
	foundXdg, err := filepath.Glob(snap.XdgRuntimeDirs())
	if err != nil {
		return nil, err
	}
	found = append(found, foundXdg...)

	// then system data
	found = append(found, snap.CommonDataDir())

	return found, nil
}
开发者ID:pedronis,项目名称:snappy,代码行数:20,代码来源:snapdata.go


注:本文中的github.com/snapcore/snapd/snap.Info.CommonDataDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。