func (env *Env) Write() { util.RemoveDir(env.dir) util.PrepareDir(env.dir) util.PrepareDir(getZenvPath()) util.PrepareDir(getEnvsPath()) env.writeInfo() env.items.Write(env.dir) if !env.global { env.addEnvDir() } }
func WriteStorage(name, key, subkey string, data []string) { if len(name) == 0 { name = STORAGE } util.PrepareDir(GetStorageDir(name, key)) util.WriteFile(getStorageFilePath(name, key, subkey), data) }
func Activate(pid string, dir string) { util.PrepareDir(getZenvPath()) envs := getEnvs(dir) settings.Initialize(getZenvPath()) for _, env := range envs { env.ReadSettings() env.Activate(pid) } }
func NewEnv(global bool, name string, recursive, exclusive bool) *Env { var dir string if global { dir = getGlobalPath(name) } else { dir = getLocalPath(name) } util.PrepareDir(dir) env := &Env{ global: global, name: name, dir: dir, recursive: recursive, exclusive: exclusive, items: make(settings.Items), } return env }
func read(name string) *Env { util.PrepareDir(path.Join(util.GetHomeDir(), zenv.ZENV, ENVS)) env := readInfo(name) return env }
func initializeLink(dir string) { pa := GetVBinPath(dir) util.RemoveDir(pa) util.PrepareDir(pa) }