From 489e26d1b3c224beffba2649406efd83580989fe Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Tue, 18 Nov 2025 20:56:12 -0800 Subject: Replace hardcoded magic values with named constants and improve type safety Adds new constants for file format identifiers (FormatFILP), fork types (ForkTypeINFO), and platform identifiers (PlatformAMAC, PlatformMWIN) to improve code maintainability and readability. Changes FlatFileForkHeader.ForkType field from [4]byte to ForkType type alias for better compile-time type checking, matching the pattern used in ForkInfoList.Fork. --- hotline/file_wrapper.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'hotline/file_wrapper.go') diff --git a/hotline/file_wrapper.go b/hotline/file_wrapper.go index b6aff94..5ec99c3 100644 --- a/hotline/file_wrapper.go +++ b/hotline/file_wrapper.go @@ -227,7 +227,7 @@ func (f *fileWrapper) flattenedFileObject() (*flattenedFileObject, error) { } f.Ffo.FlatFileHeader = FlatFileHeader{ - Format: [4]byte{0x46, 0x49, 0x4c, 0x50}, // "FILP" + Format: FormatFILP, Version: [2]byte{0, 1}, ForkCount: [2]byte{0, 2}, } @@ -247,7 +247,7 @@ func (f *fileWrapper) flattenedFileObject() (*flattenedFileObject, error) { } } else { f.Ffo.FlatFileInformationFork = FlatFileInformationFork{ - Platform: [4]byte{0x41, 0x4D, 0x41, 0x43}, // "AMAC" TODO: Remove hardcode to support "AWIN" Platform (maybe?) + Platform: PlatformAMAC, // TODO: Remove hardcode to support "MWIN" Platform (maybe?) TypeSignature: [4]byte([]byte(ft.TypeCode)), CreatorSignature: [4]byte([]byte(ft.CreatorCode)), PlatformFlags: [4]byte{0, 0, 1, 0}, // TODO: What is this? @@ -263,12 +263,12 @@ func (f *fileWrapper) flattenedFileObject() (*flattenedFileObject, error) { } f.Ffo.FlatFileInformationForkHeader = FlatFileForkHeader{ - ForkType: [4]byte{0x49, 0x4E, 0x46, 0x4F}, // "INFO" + ForkType: ForkTypeINFO, DataSize: f.Ffo.FlatFileInformationFork.Size(), } f.Ffo.FlatFileDataForkHeader = FlatFileForkHeader{ - ForkType: [4]byte{0x44, 0x41, 0x54, 0x41}, // "DATA" + ForkType: ForkTypeDATA, DataSize: [4]byte{dataSize[0], dataSize[1], dataSize[2], dataSize[3]}, } f.Ffo.FlatFileResForkHeader = f.rsrcForkHeader() -- cgit