"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
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 {
}
}
- 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