- nameEnd := 112 + bs
-
- commentSize := bytes[nameEnd : nameEnd+2]
- commentLen := binary.BigEndian.Uint16(commentSize)
-
- commentStartPos := int(nameEnd) + 2
- commentEndPos := int(nameEnd) + 2 + int(commentLen)
-
- comment := bytes[commentStartPos:commentEndPos]
-
- //dataSizeField := bytes[nameEnd+14+commentLen : nameEnd+18+commentLen]
- //dataSize := binary.BigEndian.Uint32(dataSizeField)
-
- ffo := flattenedFileObject{
- FlatFileHeader: NewFlatFileHeader(),
- FlatFileInformationForkHeader: FlatFileInformationForkHeader{
- ForkType: bytes[24:28],
- CompressionType: bytes[28:32],
- RSVD: bytes[32:36],
- DataSize: bytes[36:40],
- },
- FlatFileInformationFork: FlatFileInformationFork{
- Platform: bytes[40:44],
- TypeSignature: bytes[44:48],
- CreatorSignature: bytes[48:52],
- Flags: bytes[52:56],
- PlatformFlags: bytes[56:60],
- RSVD: bytes[60:92],
- CreateDate: bytes[92:100],
- ModifyDate: bytes[100:108],
- NameScript: bytes[108:110],
- NameSize: bytes[110:112],
- Name: bytes[112:nameEnd],
- CommentSize: bytes[nameEnd : nameEnd+2],
- Comment: comment,
- },
- FlatFileDataForkHeader: FlatFileDataForkHeader{
- ForkType: bytes[commentEndPos : commentEndPos+4],
- CompressionType: bytes[commentEndPos+4 : commentEndPos+8],
- RSVD: bytes[commentEndPos+8 : commentEndPos+12],
- DataSize: bytes[commentEndPos+12 : commentEndPos+16],
- },
+// Write implements the io.Writeer interface for FlatFileInformationFork
+func (ffif *FlatFileInformationFork) Write(p []byte) (int, error) {
+ nameSize := p[70:72]
+ bs := binary.BigEndian.Uint16(nameSize)
+ total := 72 + bs
+
+ ffif.Platform = p[0:4]
+ ffif.TypeSignature = p[4:8]
+ ffif.CreatorSignature = p[8:12]
+ ffif.Flags = p[12:16]
+ ffif.PlatformFlags = p[16:20]
+ ffif.RSVD = p[20:52]
+ ffif.CreateDate = p[52:60]
+ ffif.ModifyDate = p[60:68]
+ ffif.NameScript = p[68:70]
+ ffif.NameSize = p[70:72]
+ ffif.Name = p[72:total]
+
+ if len(p) > int(total) {
+ ffif.CommentSize = p[total : total+2]
+ commentLen := binary.BigEndian.Uint16(ffif.CommentSize)
+
+ commentStartPos := int(total) + 2
+ commentEndPos := int(total) + 2 + int(commentLen)
+
+ ffif.Comment = p[commentStartPos:commentEndPos]
+
+ total = uint16(commentEndPos)