diff options
author | Matthew Wampler-Doty <matthew.wampler.doty@gmail.com> | 2015-02-28 05:13:31 +0800 |
---|---|---|
committer | Matthew Wampler-Doty <matthew.wampler.doty@gmail.com> | 2015-02-28 05:13:31 +0800 |
commit | 3820a65299831331f215e158d287fe3df3b69ea6 (patch) | |
tree | cf7b435109c646aac576ed98eefefb57e1f27223 /ethutil | |
parent | 8653db6df0018d08212493e3a3df4677162bdd8f (diff) | |
parent | 0efd6a881afac0b3082f3b1e8780e3438eea5b02 (diff) | |
download | dexon-3820a65299831331f215e158d287fe3df3b69ea6.tar dexon-3820a65299831331f215e158d287fe3df3b69ea6.tar.gz dexon-3820a65299831331f215e158d287fe3df3b69ea6.tar.bz2 dexon-3820a65299831331f215e158d287fe3df3b69ea6.tar.lz dexon-3820a65299831331f215e158d287fe3df3b69ea6.tar.xz dexon-3820a65299831331f215e158d287fe3df3b69ea6.tar.zst dexon-3820a65299831331f215e158d287fe3df3b69ea6.zip |
Merge branch 'publictests' of github.com:ebuchman/go-ethereum into ethash_pow
Diffstat (limited to 'ethutil')
-rw-r--r-- | ethutil/common.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/ethutil/common.go b/ethutil/common.go index 2ef2440c7..c4e7415dc 100644 --- a/ethutil/common.go +++ b/ethutil/common.go @@ -3,10 +3,51 @@ package ethutil import ( "fmt" "math/big" + "os" + "os/user" + "path" + "path/filepath" "runtime" "time" + + "github.com/kardianos/osext" ) +func DefaultAssetPath() string { + var assetPath string + // If the current working directory is the go-ethereum dir + // assume a debug build and use the source directory as + // asset directory. + pwd, _ := os.Getwd() + if pwd == path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist") { + assetPath = path.Join(pwd, "assets") + } else { + switch runtime.GOOS { + case "darwin": + // Get Binary Directory + exedir, _ := osext.ExecutableFolder() + assetPath = filepath.Join(exedir, "../Resources") + case "linux": + assetPath = "/usr/share/mist" + case "windows": + assetPath = "./assets" + default: + assetPath = "." + } + } + return assetPath +} + +func DefaultDataDir() string { + usr, _ := user.Current() + if runtime.GOOS == "darwin" { + return path.Join(usr.HomeDir, "Library/Ethereum") + } else if runtime.GOOS == "windows" { + return path.Join(usr.HomeDir, "AppData/Roaming/Ethereum") + } else { + return path.Join(usr.HomeDir, ".ethereum") + } +} func IsWindows() bool { return runtime.GOOS == "windows" } |