aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil/path.go
diff options
context:
space:
mode:
Diffstat (limited to 'ethutil/path.go')
-rw-r--r--ethutil/path.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/ethutil/path.go b/ethutil/path.go
index cfbc38950..e545c8731 100644
--- a/ethutil/path.go
+++ b/ethutil/path.go
@@ -4,6 +4,7 @@ import (
"io/ioutil"
"os"
"os/user"
+ "path"
"strings"
)
@@ -11,7 +12,7 @@ func ExpandHomePath(p string) (path string) {
path = p
// Check in case of paths like "/something/~/something/"
- if path[:2] == "~/" {
+ if len(path) > 1 && path[:2] == "~/" {
usr, _ := user.Current()
dir := usr.HomeDir
@@ -58,3 +59,10 @@ func WriteFile(filePath string, content []byte) error {
return nil
}
+
+func AbsolutePath(Datadir string, filename string) string {
+ if path.IsAbs(filename) {
+ return filename
+ }
+ return path.Join(Datadir, filename)
+}