Files
galaxy-game/server/internal/repo/fs/util.go
T
2026-03-07 00:29:06 +03:00

30 lines
577 B
Go

// for windows builds func [writable] should be refactored
package fs
import (
"fmt"
"os"
)
func dirExists(path string) (bool, error) {
return pathExists(path, true)
}
func fileExists(path string) (bool, error) {
return pathExists(path, false)
}
func pathExists(path string, isDir bool) (bool, error) {
if fi, err := os.Stat(path); err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, err
} else {
if isDir != fi.IsDir() {
return false, fmt.Errorf("wrong type: "+path+" mode=%s isDir=%t", fi.Mode(), isDir)
}
return true, nil
}
}