8 const pathSeparator = "/" // File path separator TODO: make configurable to support Windows
10 // FilePathItem represents the file or directory portion of a delimited file path (e.g. foo and bar in "/foo/bar")
13 // 73 75 62 66 6f 6c 64 65 72 // "subfolder"
14 type FilePathItem struct {
19 func NewFilePathItem(b []byte) FilePathItem {
26 type FilePath struct {
28 PathItems []FilePathItem
31 func NewFilePath(b []byte) FilePath {
36 fp := FilePath{PathItemCount: b[0:2]}
38 // number of items in the path
39 pathItemLen := binary.BigEndian.Uint16(b[0:2])
41 for i := uint16(0); i < pathItemLen; i++ {
43 fp.PathItems = append(fp.PathItems, NewFilePathItem(pathData[:segLen+3]))
44 pathData = pathData[3+segLen:]
50 func (fp *FilePath) String() string {
52 for _, i := range fp.PathItems {
53 out = append(out, string(i.Name))
55 return strings.Join(out, pathSeparator)