]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/flattened_file_object.go
Updated image URL's
[rbdr/mobius] / hotline / flattened_file_object.go
index a43677b2da4a8e59302a5466aafa44e63079190e..6b8d3d9f788a948416eda05d0a8f1fd7c5b6801d 100644 (file)
@@ -55,15 +55,15 @@ type FlatFileInformationFork struct {
        Comment          []byte // File comment
 }
 
        Comment          []byte // File comment
 }
 
-func NewFlatFileInformationFork(fileName string, modifyTime []byte) FlatFileInformationFork {
+func NewFlatFileInformationFork(fileName string, modifyTime []byte, typeSignature string, creatorSignature string) FlatFileInformationFork {
        return FlatFileInformationFork{
        return FlatFileInformationFork{
-               Platform:         []byte("AMAC"),                                     // TODO: Remove hardcode to support "AWIN" Platform (maybe?)
-               TypeSignature:    []byte(fileTypeFromFilename(fileName).TypeCode),    // TODO: Don't infer types from filename
-               CreatorSignature: []byte(fileTypeFromFilename(fileName).CreatorCode), // TODO: Don't infer types from filename
-               Flags:            []byte{0, 0, 0, 0},                                 // TODO: What is this?
-               PlatformFlags:    []byte{0, 0, 1, 0},                                 // TODO: What is this?
-               RSVD:             make([]byte, 32),                                   // Unimplemented in Hotline Protocol
-               CreateDate:       modifyTime,                                         // some filesystems don't support createTime
+               Platform:         []byte("AMAC"),           // TODO: Remove hardcode to support "AWIN" Platform (maybe?)
+               TypeSignature:    []byte(typeSignature),    // TODO: Don't infer types from filename
+               CreatorSignature: []byte(creatorSignature), // TODO: Don't infer types from filename
+               Flags:            []byte{0, 0, 0, 0},       // TODO: What is this?
+               PlatformFlags:    []byte{0, 0, 1, 0},       // TODO: What is this?
+               RSVD:             make([]byte, 32),         // Unimplemented in Hotline Protocol
+               CreateDate:       modifyTime,               // some filesystems don't support createTime
                ModifyDate:       modifyTime,
                NameScript:       make([]byte, 2), // TODO: What is this?
                Name:             []byte(fileName),
                ModifyDate:       modifyTime,
                NameScript:       make([]byte, 2), // TODO: What is this?
                Name:             []byte(fileName),
@@ -72,6 +72,14 @@ func NewFlatFileInformationFork(fileName string, modifyTime []byte) FlatFileInfo
        }
 }
 
        }
 }
 
+func (ffif *FlatFileInformationFork) friendlyType() []byte {
+
+       if name, ok := friendlyCreatorNames[string(ffif.TypeSignature)]; ok {
+               return []byte(name)
+       }
+       return ffif.CreatorSignature
+}
+
 // DataSize calculates the size of the flat file information fork, which is
 // 72 bytes for the fixed length fields plus the length of the Name + Comment
 func (ffif *FlatFileInformationFork) DataSize() []byte {
 // DataSize calculates the size of the flat file information fork, which is
 // 72 bytes for the fixed length fields plus the length of the Name + Comment
 func (ffif *FlatFileInformationFork) DataSize() []byte {
@@ -195,9 +203,11 @@ func NewFlattenedFileObject(fileRoot string, filePath, fileName []byte, dataOffs
 
        mTime := toHotlineTime(fileInfo.ModTime())
 
 
        mTime := toHotlineTime(fileInfo.ModTime())
 
+       ft, _ := fileTypeFromInfo(fileInfo)
+
        return &flattenedFileObject{
                FlatFileHeader:          NewFlatFileHeader(),
        return &flattenedFileObject{
                FlatFileHeader:          NewFlatFileHeader(),
-               FlatFileInformationFork: NewFlatFileInformationFork(string(fileName), mTime),
+               FlatFileInformationFork: NewFlatFileInformationFork(string(fileName), mTime, ft.TypeCode, ft.CreatorCode),
                FlatFileDataForkHeader: FlatFileDataForkHeader{
                        ForkType:        [4]byte{0x44, 0x41, 0x54, 0x41}, // "DATA"
                        CompressionType: [4]byte{},
                FlatFileDataForkHeader: FlatFileDataForkHeader{
                        ForkType:        [4]byte{0x44, 0x41, 0x54, 0x41}, // "DATA"
                        CompressionType: [4]byte{},