]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/file_path.go
Merge pull request #49 from jhalter/fix_1.2.3_client_no_agreement_behavior
[rbdr/mobius] / hotline / file_path.go
index cdd95b9a33149f588378cec2c2014574dea4d108..460af03464cc2e5376769a30f2a1b5951cb4d785 100644 (file)
@@ -5,12 +5,10 @@ import (
        "encoding/binary"
        "errors"
        "io"
        "encoding/binary"
        "errors"
        "io"
-       "path"
+       "path/filepath"
        "strings"
 )
 
        "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
 // 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[:])
 }
 
        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 {
 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,
                fileRoot,
-               fp.String(),
-               path.Join("/", string(fileName)),
+               subPath,
+               filepath.Join("/", string(fileName)),
        )
 
        return fullPath, nil
        )
 
        return fullPath, nil