MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / HomeDirExpand

Function HomeDirExpand

utils/path.go:54–67  ·  view source on GitHub ↗

HomeDirExpand tries to expand the tilde (~) in the front of a path to a fullpath directory.

(path string)

Source from the content-addressed store, hash-verified

52// HomeDirExpand tries to expand the tilde (~) in the front of a path
53// to a fullpath directory.
54func HomeDirExpand(path string) string {
55 usr, err := user.Current()
56 if err != nil {
57 return path
58 }
59
60 if path == "~" {
61 return usr.HomeDir
62 } else if strings.HasPrefix(path, "~/") {
63 return filepath.Join(usr.HomeDir, strings.TrimPrefix(path, "~/"))
64 }
65
66 return path
67}
68
69// Exist return if file or path is exist.
70func Exist(path string) bool {

Callers 15

defaultInitFunction · 0.92
TestDefaultInitFunction · 0.92
TestOpenFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
runConsoleFunction · 0.92
configInitFunction · 0.92
getPublicFromConfigFunction · 0.92
runGenerateFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92

Calls

no outgoing calls

Tested by 3

TestDefaultInitFunction · 0.74
TestOpenFunction · 0.74
TestHomeDirExpandFunction · 0.68