aboutsummaryrefslogtreecommitdiffstats
path: root/common/path.go
diff options
context:
space:
mode:
Diffstat (limited to 'common/path.go')
-rw-r--r--common/path.go44
1 files changed, 6 insertions, 38 deletions
diff --git a/common/path.go b/common/path.go
index 1253c424c..39eacacee 100644
--- a/common/path.go
+++ b/common/path.go
@@ -23,8 +23,6 @@ import (
"path/filepath"
"runtime"
"strings"
-
- "github.com/kardianos/osext"
)
// MakeName creates a node name that follows the ethereum convention
@@ -65,48 +63,18 @@ func AbsolutePath(Datadir string, filename string) string {
return filepath.Join(Datadir, filename)
}
-func DefaultAssetPath() string {
- var assetPath string
- pwd, _ := os.Getwd()
- srcdir := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist")
-
- // If the current working directory is the go-ethereum dir
- // assume a debug build and use the source directory as
- // asset directory.
- if pwd == srcdir {
- assetPath = filepath.Join(pwd, "assets")
+func HomeDir() (home string) {
+ if usr, err := user.Current(); err == nil {
+ home = usr.HomeDir
} else {
- switch runtime.GOOS {
- case "darwin":
- // Get Binary Directory
- exedir, _ := osext.ExecutableFolder()
- assetPath = filepath.Join(exedir, "..", "Resources")
- case "linux":
- assetPath = filepath.Join("usr", "share", "mist")
- case "windows":
- assetPath = filepath.Join(".", "assets")
- default:
- assetPath = "."
- }
- }
-
- // Check if the assetPath exists. If not, try the source directory
- // This happens when binary is run from outside cmd/mist directory
- if _, err := os.Stat(assetPath); os.IsNotExist(err) {
- assetPath = filepath.Join(srcdir, "assets")
+ home = os.Getenv("HOME")
}
-
- return assetPath
+ return
}
func DefaultDataDir() string {
// Try to place the data folder in the user's home dir
- var home string
- if usr, err := user.Current(); err == nil {
- home = usr.HomeDir
- } else {
- home = os.Getenv("HOME")
- }
+ home := HomeDir()
if home != "" {
if runtime.GOOS == "darwin" {
return filepath.Join(home, "Library", "Ethereum")