Add RelativeToCwd

This commit is contained in:
Lea Anthony
2020-10-30 11:57:09 +11:00
parent 3ea069d312
commit 0f41c45de2

View File

@@ -20,6 +20,17 @@ func LocalDirectory() string {
return filepath.Dir(thisFile)
}
// RelativeToCwd returns an absolute path based on the cwd
// and the given relative path
func RelativeToCwd(relativePath string) (string, error) {
cwd, err := os.Getwd()
if err != nil {
return "", err
}
return filepath.Join(cwd, relativePath), nil
}
// Mkdir will create the given directory
func Mkdir(dirname string) error {
return os.Mkdir(dirname, 0755)