package config import ( "os" "runtime" "strings" "sync" ) // this package can provide a trivial way to track which // protobufs have been modified and need to be written to disk // todo: autogenpb could generate code to work with this var saveMap map[string]bool var saveLock sync.Mutex func init() { // init() should be avoided, but this package and for making // this small string map, it seems a sensible exception saveMap = make(map[string]bool) } func SetChanged(name string, b bool) { saveLock.Lock() defer saveLock.Unlock() saveMap[name] = b } func HasChanged(name string) bool { return saveMap[name] } // a simple function name shortcut func Exists(filename string) bool { _, err := os.Stat(Path(filename)) if os.IsNotExist(err) { return false } return true } // simple function name shortcut func IsDir(dirname string) bool { info, err := os.Stat(Path(dirname)) if os.IsNotExist(err) { return false } return info.IsDir() } // notsure if this is a thing anymore. don't care much either func Path(filename string) string { // log.Log(INFO, "Path() START filename =", filename) if runtime.GOOS == "windows" { filename = strings.Replace(filename, "/", "\\", -1) } // log.Log(INFO, "Path() END filename =", filename) return filename }