github.com/pdmccormick/importable-docker-buildx@v0.0.0-20240426161518-e47091289030/util/osutil/path.go (about) 1 package osutil 2 3 import ( 4 "os" 5 "path/filepath" 6 ) 7 8 // GetWd retrieves the current working directory. 9 // 10 // On Windows, this function will return the long path name 11 // version of the path. 12 func GetWd() string { 13 wd, _ := os.Getwd() 14 if lp, err := GetLongPathName(wd); err == nil { 15 return lp 16 } 17 return wd 18 } 19 20 func IsLocalDir(c string) bool { 21 st, err := os.Stat(c) 22 return err == nil && st.IsDir() 23 } 24 25 func ToAbs(path string) string { 26 if !filepath.IsAbs(path) { 27 path, _ = filepath.Abs(filepath.Join(GetWd(), path)) 28 } 29 return SanitizePath(path) 30 }