replaced several path.* with filepath.* which is platform independent

This commit is contained in:
Bas van Kervel
2015-05-12 14:24:11 +02:00
parent d82caa5ce3
commit b79dd188d9
18 changed files with 64 additions and 64 deletions

View File

@ -7,7 +7,6 @@ import (
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
"strings"
@ -130,10 +129,10 @@ func (sol *Solidity) Compile(source string) (contract *Contract, err error) {
_, file := filepath.Split(matches[0])
base := strings.Split(file, ".")[0]
codeFile := path.Join(wd, base+".binary")
abiDefinitionFile := path.Join(wd, base+".abi")
userDocFile := path.Join(wd, base+".docuser")
developerDocFile := path.Join(wd, base+".docdev")
codeFile := filepath.Join(wd, base+".binary")
abiDefinitionFile := filepath.Join(wd, base+".abi")
userDocFile := filepath.Join(wd, base+".docuser")
developerDocFile := filepath.Join(wd, base+".docdev")
code, err := ioutil.ReadFile(codeFile)
if err != nil {

View File

@ -4,7 +4,6 @@ import (
"fmt"
"os"
"os/user"
"path"
"path/filepath"
"runtime"
"strings"
@ -44,22 +43,22 @@ func FileExist(filePath string) bool {
}
func AbsolutePath(Datadir string, filename string) string {
if path.IsAbs(filename) {
if filepath.IsAbs(filename) {
return filename
}
return path.Join(Datadir, filename)
return filepath.Join(Datadir, filename)
}
func DefaultAssetPath() string {
var assetPath string
pwd, _ := os.Getwd()
srcdir := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist")
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 = path.Join(pwd, "assets")
assetPath = filepath.Join(pwd, "assets")
} else {
switch runtime.GOOS {
case "darwin":
@ -67,9 +66,9 @@ func DefaultAssetPath() string {
exedir, _ := osext.ExecutableFolder()
assetPath = filepath.Join(exedir, "..", "Resources")
case "linux":
assetPath = path.Join("usr", "share", "mist")
assetPath = filepath.Join("usr", "share", "mist")
case "windows":
assetPath = path.Join(".", "assets")
assetPath = filepath.Join(".", "assets")
default:
assetPath = "."
}
@ -78,7 +77,7 @@ func DefaultAssetPath() string {
// 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 = path.Join(srcdir, "assets")
assetPath = filepath.Join(srcdir, "assets")
}
return assetPath
@ -87,11 +86,11 @@ func DefaultAssetPath() string {
func DefaultDataDir() string {
usr, _ := user.Current()
if runtime.GOOS == "darwin" {
return path.Join(usr.HomeDir, "Library", "Ethereum")
return filepath.Join(usr.HomeDir, "Library", "Ethereum")
} else if runtime.GOOS == "windows" {
return path.Join(usr.HomeDir, "AppData", "Roaming", "Ethereum")
return filepath.Join(usr.HomeDir, "AppData", "Roaming", "Ethereum")
} else {
return path.Join(usr.HomeDir, ".ethereum")
return filepath.Join(usr.HomeDir, ".ethereum")
}
}