- components := strings.Split(path, string(filepath.Separator))
- var fp hotline.FilePath
-
- // Set the item count
- binary.BigEndian.PutUint16(fp.ItemCount[:], uint16(len(components)))
-
- var buffer bytes.Buffer
- err := binary.Write(&buffer, binary.BigEndian, fp.ItemCount)
- if err != nil {
- return nil, err
- }
-
- for _, component := range components {
- if component == "" {
- continue
- }
-
- if len(component) > 255 { // Ensure component size is within range
- return nil, fmt.Errorf("file path component too long")
- }
-
- // Convert to MacRoman encoding
- encodedComponent, err := txtEncoder.String(component)
- if err != nil {
- return nil, err
- }
-
- // Write length and name
- buffer.Write([]byte{0x00, 0x00, byte(len(encodedComponent))}) // Leading bytes
- buffer.Write([]byte(encodedComponent))
- }
-
- return buffer.Bytes(), nil
-}
+ components := strings.Split(path, string(filepath.Separator))
+ var fp hotline.FilePath
+ binary.BigEndian.PutUint16(fp.ItemCount[:], uint16(len(components)))