Merge pull request #933 from bas-vk/issue928

replaced path with platform aware filepath module
This commit is contained in:
Jeffrey Wilcke
2015-05-12 08:23:46 -07:00
18 changed files with 58 additions and 64 deletions

View File

@ -22,7 +22,7 @@ import (
"fmt"
"math/big"
"os"
"path"
"path/filepath"
"strings"
"github.com/ethereum/go-ethereum/cmd/utils"
@ -209,7 +209,7 @@ func (self *jsre) interactive() {
}
func (self *jsre) withHistory(op func(*os.File)) {
hist, err := os.OpenFile(path.Join(self.ethereum.DataDir, "history"), os.O_RDWR|os.O_CREATE, os.ModePerm)
hist, err := os.OpenFile(filepath.Join(self.ethereum.DataDir, "history"), os.O_RDWR|os.O_CREATE, os.ModePerm)
if err != nil {
fmt.Printf("unable to open history file: %v\n", err)
return

View File

@ -4,7 +4,6 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"regexp"
"runtime"
@ -96,7 +95,7 @@ func testJEthRE(t *testing.T) (string, *testjethre, *eth.Ethereum) {
t.Fatal(err)
}
assetPath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist", "assets", "ext")
assetPath := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist", "assets", "ext")
ds, err := docserver.New("/")
if err != nil {
t.Errorf("Error creating DocServer: %v", err)
@ -362,7 +361,7 @@ func checkEvalJSON(t *testing.T, re *testjethre, expr, want string) error {
}
if err != nil {
_, file, line, _ := runtime.Caller(1)
file = path.Base(file)
file = filepath.Base(file)
fmt.Printf("\t%s:%d: %v\n", file, line, err)
t.Fail()
}

View File

@ -26,7 +26,6 @@ import (
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"runtime"
"strconv"
@ -565,7 +564,7 @@ func upgradeDb(ctx *cli.Context) {
}
filename := fmt.Sprintf("blockchain_%d_%s.chain", bcVersion, time.Now().Format("2006-01-02_15:04:05"))
exportFile := path.Join(ctx.GlobalString(utils.DataDirFlag.Name), filename)
exportFile := filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), filename)
err = utils.ExportChain(ethereum.ChainManager(), exportFile)
if err != nil {
@ -576,7 +575,7 @@ func upgradeDb(ctx *cli.Context) {
ethereum.StateDb().Close()
ethereum.ExtraDb().Close()
os.RemoveAll(path.Join(ctx.GlobalString(utils.DataDirFlag.Name), "blockchain"))
os.RemoveAll(filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), "blockchain"))
ethereum, err = eth.New(cfg)
if err != nil {

View File

@ -27,7 +27,7 @@ import (
"fmt"
"io/ioutil"
"math/big"
"path"
"path/filepath"
"runtime"
"sort"
"time"
@ -79,7 +79,7 @@ type Gui struct {
// Create GUI, but doesn't start it
func NewWindow(ethereum *eth.Ethereum) *Gui {
db, err := ethdb.NewLDBDatabase(path.Join(ethereum.DataDir, "tx_database"))
db, err := ethdb.NewLDBDatabase(filepath.Join(ethereum.DataDir, "tx_database"))
if err != nil {
panic(err)
}
@ -92,7 +92,7 @@ func NewWindow(ethereum *eth.Ethereum) *Gui {
plugins: make(map[string]plugin),
serviceEvents: make(chan ServEv, 1),
}
data, _ := ioutil.ReadFile(path.Join(ethereum.DataDir, "plugins.json"))
data, _ := ioutil.ReadFile(filepath.Join(ethereum.DataDir, "plugins.json"))
json.Unmarshal(data, &gui.plugins)
return gui

View File

@ -26,7 +26,6 @@ import (
"io/ioutil"
"net/url"
"os"
"path"
"path/filepath"
"github.com/ethereum/go-ethereum/common"
@ -80,7 +79,7 @@ func (app *HtmlApplication) RootFolder() string {
if err != nil {
return ""
}
return path.Dir(common.WindonizePath(folder.RequestURI()))
return filepath.Dir(common.WindonizePath(folder.RequestURI()))
}
func (app *HtmlApplication) RecursiveFolders() []os.FileInfo {
files, _ := ioutil.ReadDir(app.RootFolder())

View File

@ -22,7 +22,7 @@ package main
import (
"io/ioutil"
"path"
"path/filepath"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
@ -110,7 +110,7 @@ func (ui *UiLib) ConnectToPeer(nodeURL string) {
}
func (ui *UiLib) AssetPath(p string) string {
return path.Join(ui.assetPath, p)
return filepath.Join(ui.assetPath, p)
}
func (self *UiLib) Transact(params map[string]interface{}) (string, error) {
@ -218,7 +218,7 @@ func (self *UiLib) Messages(id int) *common.List {
}
func (self *UiLib) ReadFile(p string) string {
content, err := ioutil.ReadFile(self.AssetPath(path.Join("ext", p)))
content, err := ioutil.ReadFile(self.AssetPath(filepath.Join("ext", p)))
if err != nil {
guilogger.Infoln("error reading file", p, ":", err)
}

View File

@ -7,7 +7,7 @@ import (
"math/big"
"net/http"
"os"
"path"
"path/filepath"
"runtime"
"github.com/codegangsta/cli"
@ -55,7 +55,7 @@ OPTIONS:
// NewApp creates an app with sane defaults.
func NewApp(version, usage string) *cli.App {
app := cli.NewApp()
app.Name = path.Base(os.Args[0])
app.Name = filepath.Base(os.Args[0])
app.Author = ""
//app.Authors = nil
app.Email = ""
@ -319,17 +319,17 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
func GetChain(ctx *cli.Context) (*core.ChainManager, common.Database, common.Database) {
dataDir := ctx.GlobalString(DataDirFlag.Name)
blockDb, err := ethdb.NewLDBDatabase(path.Join(dataDir, "blockchain"))
blockDb, err := ethdb.NewLDBDatabase(filepath.Join(dataDir, "blockchain"))
if err != nil {
Fatalf("Could not open database: %v", err)
}
stateDb, err := ethdb.NewLDBDatabase(path.Join(dataDir, "state"))
stateDb, err := ethdb.NewLDBDatabase(filepath.Join(dataDir, "state"))
if err != nil {
Fatalf("Could not open database: %v", err)
}
extraDb, err := ethdb.NewLDBDatabase(path.Join(dataDir, "extra"))
extraDb, err := ethdb.NewLDBDatabase(filepath.Join(dataDir, "extra"))
if err != nil {
Fatalf("Could not open database: %v", err)
}
@ -346,7 +346,7 @@ func GetChain(ctx *cli.Context) (*core.ChainManager, common.Database, common.Dat
func GetAccountManager(ctx *cli.Context) *accounts.Manager {
dataDir := ctx.GlobalString(DataDirFlag.Name)
ks := crypto.NewKeyStorePassphrase(path.Join(dataDir, "keys"))
ks := crypto.NewKeyStorePassphrase(filepath.Join(dataDir, "keys"))
return accounts.NewManager(ks)
}