Introduced `lol.Tracer` for function entry/exit logging across various packages. This improves traceability and debugging of function executions while preserving existing behavior. Removed unused files `doc.go` and `nothing.go` to clean up the repository.
32 lines
737 B
Go
32 lines
737 B
Go
package apputil
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"realy.lol/lol"
|
|
)
|
|
|
|
// EnsureDir checks a file could be written to a path, creates the directories
|
|
// as needed
|
|
func EnsureDir(fileName string) (merr error) {
|
|
lol.Tracer("EnsureDir", fileName)
|
|
defer func() { lol.Tracer("end EnsureDir", fileName) }()
|
|
dirName := filepath.Dir(fileName)
|
|
if _, serr := os.Stat(dirName); serr != nil {
|
|
merr = os.MkdirAll(dirName, os.ModePerm)
|
|
if merr != nil {
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// FileExists reports whether the named file or directory exists.
|
|
func FileExists(filePath string) (exists bool) {
|
|
lol.Tracer("FileExists", filePath)
|
|
defer func() { lol.Tracer("end FileExists", exists) }()
|
|
_, e := os.Stat(filePath)
|
|
exists = e == nil
|
|
return
|
|
}
|