MCPcopy Create free account
hub / github.com/TruthHun/BookStack / AbsolutePath

Function AbsolutePath

utils/file.go:16–31  ·  view source on GitHub ↗
(p string)

Source from the content-addressed store, hash-verified

14)
15
16func AbsolutePath(p string) (string, error) {
17
18 if strings.HasPrefix(p, "~") {
19 home := os.Getenv("HOME")
20 if home == "" {
21 panic(fmt.Sprintf("can not found HOME in envs, '%s' AbsPh Failed!", p))
22 }
23 p = fmt.Sprint(home, string(p[1:]))
24 }
25 s, err := filepath.Abs(p)
26
27 if nil != err {
28 return "", err
29 }
30 return s, nil
31}
32
33// FileExists reports whether the named file or directory exists.
34func FileExists(name string) bool {

Callers

nothing calls this directly

Calls 1

stringFunction · 0.85

Tested by

no test coverage detected