10 type FileNameWithInfo struct {
11 FileNameWithInfoHeader
12 Name []byte // File Name
14 readOffset int // Internal offset to track read progress
17 // FileNameWithInfoHeader contains the fixed length fields of FileNameWithInfo
18 type FileNameWithInfoHeader struct {
19 Type [4]byte // File type code
20 Creator [4]byte // File creator code
21 FileSize [4]byte // File Size in bytes
23 NameScript [2]byte // ??
24 NameSize [2]byte // Length of Name field
27 func (f *FileNameWithInfoHeader) nameLen() int {
28 return int(binary.BigEndian.Uint16(f.NameSize[:]))
31 // Read implements io.Reader for FileNameWithInfo
32 func (f *FileNameWithInfo) Read(p []byte) (int, error) {
43 if f.readOffset >= len(buf) {
44 return 0, io.EOF // All bytes have been read
47 n := copy(p, buf[f.readOffset:])
53 func (f *FileNameWithInfo) Write(p []byte) (int, error) {
54 err := binary.Read(bytes.NewReader(p), binary.BigEndian, &f.FileNameWithInfoHeader)
58 headerLen := binary.Size(f.FileNameWithInfoHeader)
59 f.Name = p[headerLen : headerLen+f.nameLen()]