Files
realy/apputil/apputil.go
mleku 385ec2aa27 documentation comments for apputil, auth and bech32encoding
also removed relay.damus.io which is a dumpster fire of spammers and trolls
2025-03-29 13:48:09 -01:06

25 lines
500 B
Go

package apputil
import (
"os"
"path/filepath"
)
// EnsureDir checks a file could be written to a path, creates the directories
// as needed
func EnsureDir(fileName string) {
dirName := filepath.Dir(fileName)
if _, serr := os.Stat(dirName); serr != nil {
merr := os.MkdirAll(dirName, os.ModePerm)
if merr != nil {
panic(merr)
}
}
}
// FileExists reports whether the named file or directory exists.
func FileExists(filePath string) bool {
_, e := os.Stat(filePath)
return e == nil
}