|
|
@ -313,19 +313,11 @@ func PathExists(filename string) bool {
|
|
|
|
|
|
|
|
|
|
|
|
// PathExistsWithContents returns the filename exists and it is not empty
|
|
|
|
// PathExistsWithContents returns the filename exists and it is not empty
|
|
|
|
func PathExistsWithContents(filename string) bool {
|
|
|
|
func PathExistsWithContents(filename string) bool {
|
|
|
|
if _, err := os.Stat(filename); err != nil {
|
|
|
|
info, err := os.Stat(filename)
|
|
|
|
return false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
f, err := os.Open(filename)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
return info.Size() > 4 // at least 4 bytes
|
|
|
|
|
|
|
|
|
|
|
|
r := bufio.NewReader(f)
|
|
|
|
|
|
|
|
_, err = r.Peek(4) // check first 4 bytes
|
|
|
|
|
|
|
|
return err == nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// GetEnv retrieves the environment variable key. If it does not exist it returns the default.
|
|
|
|
// GetEnv retrieves the environment variable key. If it does not exist it returns the default.
|
|
|
|