10 const pathSeparator = "/" // File path separator TODO: make configurable to support Windows
12 // FilePathItem represents the file or directory portion of a delimited file path (e.g. foo and bar in "/foo/bar")
15 // 73 75 62 66 6f 6c 64 65 72 // "subfolder"
16 type FilePathItem struct {
21 func NewFilePathItem(b []byte) FilePathItem {
28 type FilePath struct {
33 const minFilePathLen = 2
34 func (fp *FilePath) UnmarshalBinary(b []byte) error {
35 if len(b) < minFilePathLen {
36 return errors.New("insufficient bytes")
38 err := binary.Read(bytes.NewReader(b[0:2]), binary.BigEndian, &fp.ItemCount)
44 for i := uint16(0); i < fp.Len(); i++ {
46 fp.Items = append(fp.Items, NewFilePathItem(pathData[:segLen+3]))
47 pathData = pathData[3+segLen:]
53 func (fp *FilePath) Len() uint16 {
54 return binary.BigEndian.Uint16(fp.ItemCount[:])
57 func (fp *FilePath) String() string {
59 for _, i := range fp.Items {
60 out = append(out, string(i.Name))
63 return path.Join(out...)
66 func ReadFilePath(filePathFieldData []byte) string {
68 err := fp.UnmarshalBinary(filePathFieldData)