X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/7cd900d61edbd6d322db3cecb913adf574389320..67db911d966913ff04ad90018af9a5361a4d8349:/hotline/file_path.go?ds=sidebyside diff --git a/hotline/file_path.go b/hotline/file_path.go index cdd95b9..460af03 100644 --- a/hotline/file_path.go +++ b/hotline/file_path.go @@ -5,12 +5,10 @@ import ( "encoding/binary" "errors" "io" - "path" + "path/filepath" "strings" ) -const pathSeparator = "/" // File path separator TODO: make configurable to support Windows - // FilePathItem represents the file or directory portion of a delimited file path (e.g. foo and bar in "/foo/bar") // 00 00 // 09 @@ -78,15 +76,6 @@ func (fp *FilePath) Len() uint16 { return binary.BigEndian.Uint16(fp.ItemCount[:]) } -func (fp *FilePath) String() string { - out := []string{"/"} - for _, i := range fp.Items { - out = append(out, string(i.Name)) - } - - return path.Join(out...) -} - func readPath(fileRoot string, filePath, fileName []byte) (fullPath string, err error) { var fp FilePath if filePath != nil { @@ -95,11 +84,15 @@ func readPath(fileRoot string, filePath, fileName []byte) (fullPath string, err } } - fullPath = path.Join( - "/", + var subPath string + for _, pathItem := range fp.Items { + subPath = filepath.Join("/", subPath, string(pathItem.Name)) + } + + fullPath = filepath.Join( fileRoot, - fp.String(), - path.Join("/", string(fileName)), + subPath, + filepath.Join("/", string(fileName)), ) return fullPath, nil