4#include "../linker/format.h"
36 format_type type = DOUBLE;
50 hfs_type home_file_system;
52 hfs_type GetHomeFileSystem()
const;
53 void SetHomeFileSystem(hfs_type type);
55 char home_file_system_string[16] =
"";
61 offset_t file_offset = 0;
62 offset_t image_size = 0;
70 static std::shared_ptr<Entry> ReadEntry(
Linker::Reader& rd, hfs_type home_file_system);
78 virtual void CalculateValues();
84 std::shared_ptr<Linker::Contents> image;
100 void CalculateValues()
override;
104 static const char TXT_undefined[16];
105 static const char TXT_Macintosh[16];
106 static const char TXT_ProDOS[16];
107 static const char TXT_MS_DOS[16];
108 static const char TXT_UNIX[16];
109 static const char TXT_VAX_VMS[16];
112 std::vector<std::shared_ptr<Entry>> entries;
113 offset_t image_size = offset_t(-1);
126 ID_MacintoshFileInfo,
136 SetHomeFileSystem(HFS_UNDEFINED);
139 AppleSingleDouble(format_type type,
unsigned version, hfs_type home_file_system)
140 : type(type), version(version)
142 assert(type == SINGLE || type == DOUBLE);
143 SetHomeFileSystem(version == 1 ? home_file_system : HFS_UNDEFINED);
146 AppleSingleDouble(format_type type, hfs_type home_file_system)
147 : type(type), version(1), home_file_system(home_file_system)
149 assert(type == SINGLE || type == DOUBLE);
150 SetHomeFileSystem(home_file_system);
153 AppleSingleDouble(format_type type,
unsigned version = 2)
154 : type(type), version(version), home_file_system(HFS_UNDEFINED)
156 assert(type == SINGLE || type == DOUBLE);
157 SetHomeFileSystem(HFS_UNDEFINED);
161 explicit AppleSingleDouble(AppleSingleDouble& other, format_type type)
162 : type(type), version(other.version), home_file_system(other.home_file_system)
164 SetHomeFileSystem(other.GetHomeFileSystem());
165 if(type == SINGLE && other.type == DOUBLE)
169 for(
auto entry : other.entries)
171 if(type == DOUBLE && entry->id == ID_DataFork)
173 entries.push_back(entry);
177 explicit AppleSingleDouble(AppleSingleDouble& other)
178 : type(other.type), version(other.version), home_file_system(other.home_file_system)
180 for(
auto entry : other.entries)
182 entries.push_back(entry);
186 std::shared_ptr<const Entry> FindEntry(uint32_t
id)
const;
187 std::shared_ptr<Entry> FindEntry(uint32_t
id);
188 void AppendEntry(std::shared_ptr<Entry> entry);
190 std::shared_ptr<Entry> GetFileDatesInfo();
191 std::shared_ptr<Entry> GetMacintoshFileInfo();
192 std::shared_ptr<Entry> GetAUXFileInfo();
193 std::shared_ptr<Entry> GetProDOSFileInfo();
194 std::shared_ptr<Entry> GetMSDOSFileInfo();
196 std::shared_ptr<Entry> GetDataFork();
197 std::shared_ptr<Entry> GetResourceFork();
198 std::shared_ptr<Entry> GetFinderInfo();
199 std::shared_ptr<Entry> GetRealName();
201 void SetCreationDate(uint32_t CreationDate);
202 void SetModificationDate(uint32_t ModificationDate);
203 void SetBackupDate(uint32_t BackupDate);
204 void SetAccessDate(uint32_t AccessDate);
205 void SetMacintoshAttributes(uint32_t Attributes);
206 void SetProDOSAccess(uint16_t Access);
207 void SetProDOSFileType(uint16_t FileType);
208 void SetProDOSAUXType(uint32_t AUXType);
209 void SetMSDOSAttributes(uint16_t Attributes);
225 void CalculateValues();
230 std::string PrefixFilename(std::string prefix, std::string filename);
231 std::string PrefixFilename(std::string prefix, std::string filename,
size_t limit);
232 std::string ReplaceExtension(std::string filename, std::string extension,
size_t limit);
234 std::string GetUNIXDoubleFilename(std::string filename);
235 std::string GetMacOSXDoubleFilename(std::string filename);
236 std::string GetProDOSDoubleFilename(std::string filename);
237 std::string GetMSDOSDoubleFilename(std::string filename);
243 std::shared_ptr<Linker::Contents> image;
246 : Entry(AppleSingleDouble::ID_DataFork)
250 DataFork(std::shared_ptr<Linker::Contents> image)
251 : Entry(AppleSingleDouble::ID_DataFork), image(image)
264 void CalculateValues()
override;
275 std::shared_ptr<Linker::Contents>
image;
296 void CalculateValues()
override;
305 : Entry(AppleSingleDouble::ID_RealName), name(name)
323 : Entry(AppleSingleDouble::ID_Comment)
342 : Entry(AppleSingleDouble::ID_IconBW)
361 : Entry(AppleSingleDouble::ID_IconColor)
381 : Entry(AppleSingleDouble::ID_FileInfo)
395 uint32_t CreationDate;
396 uint32_t ModificationDate;
397 uint32_t LastBackupDate;
401 uint32_t ModificationDate = 0,
402 uint32_t LastBackupDate = 0,
403 uint32_t Attributes = 0)
404 : CreationDate(CreationDate), ModificationDate(ModificationDate), LastBackupDate(LastBackupDate), Attributes(Attributes)
421 uint32_t CreationDate;
422 uint32_t ModificationDate;
427 ProDOS(uint32_t CreationDate = 0,
428 uint32_t ModificationDate = 0,
430 uint16_t FileType = 0,
431 uint32_t AUXType = 0)
432 : CreationDate(CreationDate), ModificationDate(ModificationDate), Access(Access), FileType(FileType), AUXType(AUXType)
449 uint32_t ModificationDate;
452 MSDOS(uint32_t ModificationDate = 0,
453 uint16_t Attributes = 0)
454 : ModificationDate(ModificationDate), Attributes(Attributes)
471 uint32_t CreationDate;
473 uint32_t ModificationDate;
475 AUX(uint32_t CreationDate = 0,
476 uint32_t AccessDate = 0,
477 uint32_t ModificationDate = 0)
478 : CreationDate(CreationDate), AccessDate(AccessDate), ModificationDate(ModificationDate)
496 uint32_t CreationDate;
497 uint32_t ModificationDate;
502 uint32_t CreationDate = 0,
503 uint32_t ModificationDate = 0,
504 uint32_t BackupDate = 0,
505 uint32_t AccessDate = 0)
506 : Entry(AppleSingleDouble::ID_FileDatesInfo),
507 CreationDate(CreationDate), ModificationDate(ModificationDate), BackupDate(BackupDate), AccessDate(AccessDate)
529 char Type[4] = {
'?',
'?',
'?',
'?' };
530 char Creator[4] = {
'?',
'?',
'?',
'?' };
532 Point Location = { 0, 0 };
535 : Entry(AppleSingleDouble::ID_FinderInfo)
548 void SetTypeAndCreator(std::string type, std::string creator);
557 : Entry(AppleSingleDouble::ID_MacintoshFileInfo), Attributes(Attributes)
580 uint16_t FileType = 0,
581 uint32_t AUXType = 0)
582 : Entry(AppleSingleDouble::ID_ProDOSFileInfo), Access(Access), FileType(FileType), AUXType(AUXType)
603 : Entry(AppleSingleDouble::ID_MSDOSFileInfo), Attributes(Attributes)
622 : Entry(AppleSingleDouble::ID_AFPShortName)
642 : Entry(AppleSingleDouble::ID_AFPFileInfo)
662 : Entry(AppleSingleDouble::ID_AFPDirectoryID)
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1495
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1479
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1484
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1489
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1461
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1466
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1472
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1456
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1433
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1449
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1443
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1438
offset_t WriteFile(Linker::Writer &out) const override=0
Stores data in memory to file.
offset_t ImageSize() const override=0
Retrieves size of stored data.
void ReadFile(Linker::Reader &rd) override=0
Loads file into memory.
void Dump(Dumper::Dumper &dump) const override=0
Display file contents in a nice manner.
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:241
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:223
offset_t WriteFile(Linker::Writer &out) const override
Stores data in memory to file.
Definition apple.cc:228
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:218
AppleSingle & AppleDouble.
Definition apple.h:26
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:53
uint32_t GetModificationDate()
Retrieves modification date field and creates it if it does not exist.
Definition apple.cc:599
uint32_t GetCreationDate()
Retrieves creation date field and creates it if it does not exist.
Definition apple.cc:495
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:878
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:16
uint32_t ReadCreationDate()
Retrieves creation date field if it exists.
Definition apple.cc:530
uint32_t ReadMacintoshAttributes()
Retrieves Macintosh attributes field if it exists.
Definition apple.cc:744
uint32_t GetMacintoshAttributes()
Retrieves Macintosh attributes field and creates it if it does not exist.
Definition apple.cc:728
uint32_t ReadModificationDate()
Retrieves modification date field if it exists.
Definition apple.cc:640
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:857
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:955
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:980
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:950
offset_t WriteFile(Linker::Writer &out) const override
Stores data in memory to file.
Definition apple.cc:967
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1284
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1274
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1295
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1279
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1247
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1252
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1257
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1267
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1226
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1221
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1231
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1240
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1169
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1174
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1185
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1164
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1202
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1214
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1197
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1192
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1307
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1302
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1312
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1326
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1118
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1123
offset_t WriteFile(Linker::Writer &out) const override
Stores data in memory to file.
Definition apple.cc:1128
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1134
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1146
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1141
offset_t WriteFile(Linker::Writer &out) const override
Stores data in memory to file.
Definition apple.cc:1151
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1157
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1418
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1413
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1408
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1426
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1356
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1366
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1361
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1374
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1381
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1386
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1401
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1391
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1070
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1088
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1075
offset_t WriteFile(Linker::Writer &wr) const override
Stores data in memory to file.
Definition apple.cc:1080
Container for a resource fork.
Definition apple.h:272
offset_t WriteFile(Linker::Writer &out) const override
Stores data in memory to file.
Definition apple.cc:1029
std::shared_ptr< Linker::Contents > image
The actual resource image, for example Apple::MacintoshResourceFileFormat.
Definition apple.h:275
offset_t ImageSize() const override
Retrieves size of stored data.
Definition apple.cc:1008
void ReadFile(Linker::Reader &rd) override
Loads file into memory.
Definition apple.cc:1013
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1042
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:828
A helper class, encapsulating functionality needed to import binary data.
Definition reader.h:20
A helper class, encapsulating functionality needed to export binary data.
Definition writer.h:15