aboutsummaryrefslogtreecommitdiff
path: root/go
diff options
context:
space:
mode:
authorchrislusf <chris.lu@gmail.com>2015-07-08 01:43:26 -0700
committerchrislusf <chris.lu@gmail.com>2015-07-08 01:43:26 -0700
commit95855da2824c90f0aeaaa2782e66b10ef02c0242 (patch)
tree35ba2c108eb661d0fe4abd76c76bb9692644da8c /go
parent3b2645979de34795908ba6ca2d8d94a087d1619c (diff)
downloadseaweedfs-95855da2824c90f0aeaaa2782e66b10ef02c0242.tar.xz
seaweedfs-95855da2824c90f0aeaaa2782e66b10ef02c0242.zip
Adjust for window path
fix https://github.com/chrislusf/seaweedfs/issues/161
Diffstat (limited to 'go')
-rw-r--r--go/filer/embedded_filer/directory_in_map.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/go/filer/embedded_filer/directory_in_map.go b/go/filer/embedded_filer/directory_in_map.go
index cd8fb3e18..a1679f93e 100644
--- a/go/filer/embedded_filer/directory_in_map.go
+++ b/go/filer/embedded_filer/directory_in_map.go
@@ -62,7 +62,7 @@ func NewDirectoryManagerInMap(dirLogFile string) (dm *DirectoryManagerInMap, err
//dm.Root do not use NewDirectoryEntryInMap, since dm.max will be changed
dm.Root = &DirectoryEntryInMap{SubDirectories: make(map[string]*DirectoryEntryInMap)}
if dm.logFile, err = os.OpenFile(dirLogFile, os.O_RDWR|os.O_CREATE, 0644); err != nil {
- return nil, fmt.Errorf("cannot write directory log file %s.idx: %v", dirLogFile, err)
+ return nil, fmt.Errorf("cannot write directory log file %s: %v", dirLogFile, err)
}
return dm, dm.load()
}
@@ -128,7 +128,7 @@ func (dm *DirectoryManagerInMap) findDirectory(dirPath string) (*DirectoryEntryI
if dirPath == "" {
return dm.Root, nil
}
- dirPath = filepath.Clean(dirPath)
+ dirPath = CleanFilePath(dirPath)
if dirPath == "/" {
return dm.Root, nil
}
@@ -152,7 +152,7 @@ func (dm *DirectoryManagerInMap) FindDirectory(dirPath string) (filer.DirectoryI
}
func (dm *DirectoryManagerInMap) loadDirectory(dirPath string, dirId filer.DirectoryId) error {
- dirPath = filepath.Clean(dirPath)
+ dirPath = CleanFilePath(dirPath)
if dirPath == "/" {
return nil
}
@@ -180,7 +180,7 @@ func (dm *DirectoryManagerInMap) loadDirectory(dirPath string, dirId filer.Direc
}
func (dm *DirectoryManagerInMap) makeDirectory(dirPath string) (dir *DirectoryEntryInMap, created bool) {
- dirPath = filepath.Clean(dirPath)
+ dirPath = CleanFilePath(dirPath)
if dirPath == "/" {
return dm.Root, false
}
@@ -257,3 +257,11 @@ func (dm *DirectoryManagerInMap) DeleteDirectory(dirPath string) error {
dm.log("del", dirPath)
return nil
}
+
+func CleanFilePath(fp string) string {
+ ret := filepath.Clean(fp)
+ if os.PathSeparator == '\\' {
+ return strings.Replace(ret, "\\", "/", -1)
+ }
+ return ret
+}