10 type FileNameWithInfo struct {
11 fileNameWithInfoHeader
12 Name []byte // File Name
15 // fileNameWithInfoHeader contains the fixed length fields of FileNameWithInfo
16 type fileNameWithInfoHeader struct {
17 Type [4]byte // File type code
18 Creator [4]byte // File creator code
19 FileSize [4]byte // File Size in bytes
21 NameScript [2]byte // ??
22 NameSize [2]byte // Length of Name field
25 func (f *fileNameWithInfoHeader) nameLen() int {
26 return int(binary.BigEndian.Uint16(f.NameSize[:]))
29 // Read implements io.Reader for FileNameWithInfo
30 func (f *FileNameWithInfo) Read(b []byte) (int, error) {
44 func (f *FileNameWithInfo) Write(p []byte) (int, error) {
45 err := binary.Read(bytes.NewReader(p), binary.BigEndian, &f.fileNameWithInfoHeader)
49 headerLen := binary.Size(f.fileNameWithInfoHeader)
50 f.Name = p[headerLen : headerLen+f.nameLen()]