X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/050407a3b7f719ed6ce9367eb803bf948075e50e..da5bdd82beef668f49c2cec09cea85435c0bec34:/hotline/file_path.go diff --git a/hotline/file_path.go b/hotline/file_path.go index 3ff2435..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,24 +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 ReadFilePath(filePathFieldData []byte) string { - var fp FilePath - err := fp.UnmarshalBinary(filePathFieldData) - if err != nil { - // TODO - } - return fp.String() -} - func readPath(fileRoot string, filePath, fileName []byte) (fullPath string, err error) { var fp FilePath if filePath != nil { @@ -104,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