diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-10-01 19:03:04 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-10-01 19:03:04 +0800 |
commit | 581c0901af22d678aedd9eefae6144582c23e1a0 (patch) | |
tree | b8693e5ee2bb8cc4c3bd5e5f57631d6b72ff9bc8 /common | |
parent | e3ac56d50277316a880617416d9823cf70dd059a (diff) | |
parent | 74578ab22b24af99ff774927a18153f464334706 (diff) | |
download | dexon-581c0901af22d678aedd9eefae6144582c23e1a0.tar dexon-581c0901af22d678aedd9eefae6144582c23e1a0.tar.gz dexon-581c0901af22d678aedd9eefae6144582c23e1a0.tar.bz2 dexon-581c0901af22d678aedd9eefae6144582c23e1a0.tar.lz dexon-581c0901af22d678aedd9eefae6144582c23e1a0.tar.xz dexon-581c0901af22d678aedd9eefae6144582c23e1a0.tar.zst dexon-581c0901af22d678aedd9eefae6144582c23e1a0.zip |
Merge pull request #1856 from karalabe/andorid-path-fix
common: fix #1818, secondary datadir paths to fall back to
Diffstat (limited to 'common')
-rw-r--r-- | common/path.go | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/common/path.go b/common/path.go index 8b3c7d14b..1253c424c 100644 --- a/common/path.go +++ b/common/path.go @@ -100,14 +100,24 @@ func DefaultAssetPath() string { } func DefaultDataDir() string { - usr, _ := user.Current() - if runtime.GOOS == "darwin" { - return filepath.Join(usr.HomeDir, "Library", "Ethereum") - } else if runtime.GOOS == "windows" { - return filepath.Join(usr.HomeDir, "AppData", "Roaming", "Ethereum") + // 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 { - return filepath.Join(usr.HomeDir, ".ethereum") + home = os.Getenv("HOME") } + if home != "" { + if runtime.GOOS == "darwin" { + return filepath.Join(home, "Library", "Ethereum") + } else if runtime.GOOS == "windows" { + return filepath.Join(home, "AppData", "Roaming", "Ethereum") + } else { + return filepath.Join(home, ".ethereum") + } + } + // As we cannot guess a stable location, return empty and handle later + return "" } func DefaultIpcPath() string { |