Fix to set the application CWD to the HOME directory (#122)

This commit is contained in:
akiyosi 2020-06-06 22:33:04 +09:00
parent 2c24538941
commit 2307784a46
3 changed files with 30 additions and 13 deletions

View file

@ -2,6 +2,8 @@ package util
import (
"strings"
"os/user"
"path/filepath"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
@ -268,3 +270,15 @@ func NewVFlowLayout(spacing int, padding int, paddingTop int, rightIdex int, wid
})
return layout
}
func ExpandTildeToHomeDirectory(path string) (string, error) {
if len(path) == 0 || path[0] != '~' {
return path, nil
}
usr, err := user.Current()
if err != nil {
return "", err
}
return filepath.Join(usr.HomeDir, path[1:]), nil
}