aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil/common.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-02-27 03:21:16 +0800
committerobscuren <geffobscura@gmail.com>2015-02-27 03:21:16 +0800
commitfa7deb10f636d89f668249b78792f8cc48146ee8 (patch)
treea9531d9e14c15abd72625a98a21a9b988dc32319 /ethutil/common.go
parentb2a225a52e45315f3ec90e11707fefa6059d13f5 (diff)
parente235b57234a68a8a39cfe7691a1825d8c6bb3443 (diff)
downloadgo-tangerine-fa7deb10f636d89f668249b78792f8cc48146ee8.tar
go-tangerine-fa7deb10f636d89f668249b78792f8cc48146ee8.tar.gz
go-tangerine-fa7deb10f636d89f668249b78792f8cc48146ee8.tar.bz2
go-tangerine-fa7deb10f636d89f668249b78792f8cc48146ee8.tar.lz
go-tangerine-fa7deb10f636d89f668249b78792f8cc48146ee8.tar.xz
go-tangerine-fa7deb10f636d89f668249b78792f8cc48146ee8.tar.zst
go-tangerine-fa7deb10f636d89f668249b78792f8cc48146ee8.zip
Merge branch 'develop'
Diffstat (limited to 'ethutil/common.go')
-rw-r--r--ethutil/common.go41
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"
}