RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
apple.h
1#ifndef APPLE_H
2#define APPLE_H
3
4#include "../dumper/dumper.h"
5#include "../linker/format.h"
6
7/* Structures common to multiple Apple products */
8
11
12namespace Apple
13{
14 /* TODO: rework with Linker::Format */
15
30 {
31 public:
34 using Timestamp = ::Timestamp<clock>;
35
36 offset_t ImageSize() const override;
37 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
38
39 enum format_type
40 {
41 SINGLE = 0x00051600,
42 DOUBLE = 0x00051607,
43 };
44 format_type type = DOUBLE;
45 unsigned version = 2;
46
47 /* Only relevant for version 1 */
48 enum hfs_type
49 {
50 HFS_UNDEFINED,
51 HFS_Macintosh,
52 HFS_ProDOS,
53 HFS_MSDOS,
54 HFS_UNIX,
55 HFS_VAX_VMS,
56 };
57 protected:
58 hfs_type home_file_system;
59 public:
60 hfs_type GetHomeFileSystem() const;
61 void SetHomeFileSystem(hfs_type type);
62
63 char home_file_system_string[16] = "";
64
65 class Entry : public virtual Linker::Format
66 {
67 public:
68 const uint32_t id;
69 offset_t file_offset = 0;
70 offset_t image_size = 0;
71 protected:
72 Entry(uint32_t id)
73 : id(id)
74 {
75 }
76 public:
77 offset_t ImageSize() const override = 0;
78 static std::shared_ptr<Entry> ReadEntry(const std::shared_ptr<Linker::Reader>& rd, hfs_type home_file_system);
79 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override = 0;
81 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& out) const override = 0;
82 void Dump(Dumper::Dumper& dump) const override = 0;
83
84 void DumpEntry(Dumper::Dumper& dump, unsigned index) const;
85 };
86
87 class GenericEntry : public Entry
88 {
89 public:
90 std::shared_ptr<Linker::Contents> image;
91
92 GenericEntry(uint32_t id)
93 : Entry(id)
94 {
95 }
96
97 GenericEntry(uint32_t id, std::shared_ptr<Linker::Contents> image)
98 : Entry(id), image(image)
99 {
100 }
101
102 offset_t ImageSize() const override;
103
104 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
105
107 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& out) const override;
108
109 void Dump(Dumper::Dumper& dump) const override;
110 };
111
112 static const char TXT_undefined[16];
113 static const char TXT_Macintosh[16];
114 static const char TXT_ProDOS[16];
115 static const char TXT_MS_DOS[16];
116 static const char TXT_UNIX[16];
117 static const char TXT_VAX_VMS[16];
118
119 std::vector<std::shared_ptr<Entry>> entries;
120 offset_t image_size = offset_t(-1);
121
122 enum
123 {
124 ID_DataFork = 1,
125 ID_ResourceFork,
126 ID_RealName,
127 ID_Comment,
128 ID_IconBW,
129 ID_IconColor,
130 ID_FileInfo, /* v1 only */
131 ID_FileDatesInfo, /* v2 only */
132 ID_FinderInfo,
133 ID_MacintoshFileInfo, /* v2 only */
134 ID_ProDOSFileInfo, /* v2 only */
135 ID_MSDOSFileInfo, /* v2 only */
136 ID_AFPShortName, /* v2 only */
137 ID_AFPFileInfo, /* v2 only */
138 ID_AFPDirectoryID, /* v2 only */
139 };
140
141 explicit AppleSingleDouble()
142 {
143 SetHomeFileSystem(HFS_UNDEFINED);
144 }
145
146 AppleSingleDouble(format_type type, unsigned version, hfs_type home_file_system)
147 : type(type), version(version)
148 {
149 assert(type == SINGLE || type == DOUBLE);
150 SetHomeFileSystem(version == 1 ? home_file_system : HFS_UNDEFINED);
151 }
152
153 AppleSingleDouble(format_type type, hfs_type home_file_system)
154 : type(type), version(1), home_file_system(home_file_system)
155 {
156 assert(type == SINGLE || type == DOUBLE);
157 SetHomeFileSystem(home_file_system);
158 }
159
160 AppleSingleDouble(format_type type, unsigned version = 2)
161 : type(type), version(version), home_file_system(HFS_UNDEFINED)
162 {
163 assert(type == SINGLE || type == DOUBLE);
164 SetHomeFileSystem(HFS_UNDEFINED);
165 }
166
167 /* TODO: a destructor might remove the entries of the other object as well */
168 explicit AppleSingleDouble(AppleSingleDouble& other, format_type type)
169 : type(type), version(other.version), home_file_system(other.home_file_system)
170 {
171 SetHomeFileSystem(other.GetHomeFileSystem());
172 if(type == SINGLE && other.type == DOUBLE)
173 {
174 GetDataFork();
175 }
176 for(auto entry : other.entries)
177 {
178 if(type == DOUBLE && entry->id == ID_DataFork)
179 continue;
180 entries.push_back(entry);
181 }
182 }
183
184 explicit AppleSingleDouble(AppleSingleDouble& other)
185 : type(other.type), version(other.version), home_file_system(other.home_file_system)
186 {
187 for(auto entry : other.entries)
188 {
189 entries.push_back(entry);
190 }
191 }
192
193 std::shared_ptr<const Entry> FindEntry(uint32_t id) const;
194 std::shared_ptr<Entry> FindEntry(uint32_t id);
195 void AppendEntry(std::shared_ptr<Entry> entry);
196
197 std::shared_ptr<Entry> GetFileDatesInfo();
198 std::shared_ptr<Entry> GetMacintoshFileInfo();
199 std::shared_ptr<Entry> GetAUXFileInfo();
200 std::shared_ptr<Entry> GetProDOSFileInfo();
201 std::shared_ptr<Entry> GetMSDOSFileInfo();
202
203 std::shared_ptr<Entry> GetDataFork();
204 std::shared_ptr<Entry> GetResourceFork();
205 std::shared_ptr<Entry> GetFinderInfo();
206 std::shared_ptr<Entry> GetRealName();
207
208 void SetCreationDate(Timestamp CreationDate);
209 void SetModificationDate(Timestamp ModificationDate);
210 void SetBackupDate(Timestamp BackupDate);
211 void SetAccessDate(Timestamp AccessDate);
212 void SetMacintoshAttributes(uint32_t Attributes);
213 void SetProDOSAccess(uint16_t Access);
214 void SetProDOSFileType(uint16_t FileType);
215 void SetProDOSAuxiliaryType(uint32_t AuxiliaryType);
216 void SetMSDOSAttributes(uint16_t Attributes);
217
219 Timestamp GetCreationDate();
221 Timestamp GetModificationDate();
223 uint32_t GetMacintoshAttributes();
224
226 std::optional<Timestamp> ReadCreationDate();
228 std::optional<Timestamp> ReadModificationDate();
230 uint32_t ReadMacintoshAttributes();
231
232 void CalculateOffsets();
234 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
235 void Dump(Dumper::Dumper& dump) const override;
236
237 std::string PrefixFilename(std::string prefix, std::string filename);
238 std::string PrefixFilename(std::string prefix, std::string filename, size_t limit);
239 std::string ReplaceExtension(std::string filename, std::string extension, size_t limit);
240
241 std::string GetUNIXDoubleFilename(std::string filename);
242 std::string GetMacOSXDoubleFilename(std::string filename);
243 std::string GetProDOSDoubleFilename(std::string filename);
244 std::string GetMSDOSDoubleFilename(std::string filename);
245 };
246
247#if 0
252#endif
253
255 {
256 public:
257 std::string name;
258
259 RealName(std::string name = "")
260 : Entry(AppleSingleDouble::ID_RealName), name(name)
261 {
262 }
263
264 offset_t ImageSize() const override;
265
266 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
267
269 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
270
271 void Dump(Dumper::Dumper& dump) const override;
272 };
273
275 {
276 public:
277 IconBW()
278 : Entry(AppleSingleDouble::ID_IconBW)
279 {
280 }
281 /* TODO - this is a stub */
282
283 offset_t ImageSize() const override;
284
285 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
287
288 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& out) const override;
289
290 void Dump(Dumper::Dumper& dump) const override;
291 };
292
294 {
295 public:
296 IconColor()
297 : Entry(AppleSingleDouble::ID_IconColor)
298 {
299 }
300 /* TODO - this is a stub */
301
302 offset_t ImageSize() const override;
303
304 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
306
307 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& out) const override;
308
309 void Dump(Dumper::Dumper& dump) const override;
310 };
311
312 /* Version 1 only */
314 {
315 protected:
316 FileInfo()
317 : Entry(AppleSingleDouble::ID_FileInfo)
318 {
319 }
320
321 public:
322 class Macintosh;
323 class ProDOS;
324 class MSDOS;
325 class AUX;
326 };
327
329 {
330 public:
331 AppleSingleDouble::Timestamp CreationDate;
332 AppleSingleDouble::Timestamp ModificationDate;
333 AppleSingleDouble::Timestamp LastBackupDate;
334 uint32_t Attributes;
335
336 Macintosh(AppleSingleDouble::Timestamp CreationDate = { },
337 AppleSingleDouble::Timestamp ModificationDate = { },
338 AppleSingleDouble::Timestamp LastBackupDate = { },
339 uint32_t Attributes = 0)
340 : CreationDate(CreationDate), ModificationDate(ModificationDate), LastBackupDate(LastBackupDate), Attributes(Attributes)
341 {
342 }
343
344 offset_t ImageSize() const override;
345
346 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
347
349 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
350
351 void Dump(Dumper::Dumper& dump) const override;
352 };
353
355 {
356 public:
357 AppleSingleDouble::Timestamp CreationDate;
358 AppleSingleDouble::Timestamp ModificationDate;
359 uint16_t Access;
360 uint16_t FileType;
361 uint32_t AuxiliaryType;
362
363 ProDOS(AppleSingleDouble::Timestamp CreationDate = { },
364 AppleSingleDouble::Timestamp ModificationDate = { },
365 uint16_t Access = 0,
366 uint16_t FileType = 0,
367 uint32_t AuxiliaryType = 0)
368 : CreationDate(CreationDate), ModificationDate(ModificationDate), Access(Access), FileType(FileType), AuxiliaryType(AuxiliaryType)
369 {
370 }
371
372 offset_t ImageSize() const override;
373
374 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
375
377 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
378
379 void Dump(Dumper::Dumper& dump) const override;
380 };
381
383 {
384 public:
385 AppleSingleDouble::Timestamp ModificationDate;
386 uint16_t Attributes;
387
388 MSDOS(AppleSingleDouble::Timestamp ModificationDate = { },
389 uint16_t Attributes = 0)
390 : ModificationDate(ModificationDate), Attributes(Attributes)
391 {
392 }
393
394 offset_t ImageSize() const override;
395
396 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
397
399 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
400
401 void Dump(Dumper::Dumper& dump) const override;
402 };
403
404 class FileInfo::AUX : public FileInfo
405 {
406 public:
407 AppleSingleDouble::Timestamp CreationDate;
408 AppleSingleDouble::Timestamp AccessDate;
409 AppleSingleDouble::Timestamp ModificationDate;
410
411 AUX(AppleSingleDouble::Timestamp CreationDate = { },
412 AppleSingleDouble::Timestamp AccessDate = { },
413 AppleSingleDouble::Timestamp ModificationDate = { })
414 : CreationDate(CreationDate), AccessDate(AccessDate), ModificationDate(ModificationDate)
415 {
416 }
417
418 offset_t ImageSize() const override;
419
420 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
421
423 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
424
425 void Dump(Dumper::Dumper& dump) const override;
426 };
427
428 /* Version 2 only */
430 {
431 public:
432 AppleSingleDouble::Timestamp CreationDate;
433 AppleSingleDouble::Timestamp ModificationDate;
434 AppleSingleDouble::Timestamp BackupDate;
435 AppleSingleDouble::Timestamp AccessDate;
436
438 AppleSingleDouble::Timestamp CreationDate = { },
439 AppleSingleDouble::Timestamp ModificationDate = { },
440 AppleSingleDouble::Timestamp BackupDate = { },
441 AppleSingleDouble::Timestamp AccessDate = { })
442 : Entry(AppleSingleDouble::ID_FileDatesInfo),
443 CreationDate(CreationDate), ModificationDate(ModificationDate), BackupDate(BackupDate), AccessDate(AccessDate)
444 {
445 }
446
447 offset_t ImageSize() const override;
448
449 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
450
452 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
453
454 void Dump(Dumper::Dumper& dump) const override;
455 static void DumpFields(Dumper::Region& region, std::optional<AppleSingleDouble::Timestamp> CreationDate, std::optional<AppleSingleDouble::Timestamp> ModificationDate, std::optional<AppleSingleDouble::Timestamp> BackupDate, std::optional<AppleSingleDouble::Timestamp> AccessDate);
456 };
457
459 {
460 public:
461 struct Point
462 {
463 int16_t x, y;
464 };
465
466 // file information
467 char Type[4] = { '?', '?', '?', '?' };
468 char Creator[4] = { '?', '?', '?', '?' };
469 int16_t Flags = 0;
470 Point Location = { 0, 0 };
471 int16_t Folder = 0;
472 // extended file information
473 int16_t IconID = 0;
474 int8_t Script = 0;
475 int16_t CommentID = 0;
476 int32_t HomeDirectoryID = 0;
477
478 FinderInfo()
479 : Entry(AppleSingleDouble::ID_FinderInfo)
480 {
481 }
482
483 offset_t ImageSize() const override;
484
485 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
486
488 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
489
490 void Dump(Dumper::Dumper& dump) const override;
491
492 void SetTypeAndCreator(std::string type, std::string creator);
493 };
494
495 /* Version 2 only */
497 {
498 public:
499 uint32_t Attributes;
500 MacintoshFileInfo(uint32_t Attributes = 0)
501 : Entry(AppleSingleDouble::ID_MacintoshFileInfo), Attributes(Attributes)
502 {
503 }
504
505 offset_t ImageSize() const override;
506
507 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
508
510 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
511
512 void Dump(Dumper::Dumper& dump) const override;
513 static void DumpFields(Dumper::Region& region, uint32_t Attributes);
514 };
515
516 /* Version 2 only */
518 {
519 public:
520 uint16_t Access;
521 uint16_t FileType;
522 uint32_t AuxiliaryType;
523
524 ProDOSFileInfo(uint16_t Access = 0,
525 uint16_t FileType = 0,
526 uint32_t AuxiliaryType = 0)
527 : Entry(AppleSingleDouble::ID_ProDOSFileInfo), Access(Access), FileType(FileType), AuxiliaryType(AuxiliaryType)
528 {
529 }
530
531 offset_t ImageSize() const override;
532
533 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
534
536 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
537
538 void Dump(Dumper::Dumper& dump) const override;
539 static void DumpFields(Dumper::Region& region, uint16_t Access, uint16_t FileType, uint32_t AuxiliaryType);
540 };
541
542 /* Version 2 only */
544 {
545 public:
546 uint16_t Attributes;
547
548 MSDOSFileInfo(uint16_t Attributes = 0)
549 : Entry(AppleSingleDouble::ID_MSDOSFileInfo), Attributes(Attributes)
550 {
551 }
552
553 offset_t ImageSize() const override;
554
555 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
556
558 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
559
560 void Dump(Dumper::Dumper& dump) const override;
561 static void DumpFields(Dumper::Region& region, uint16_t Attributes);
562 };
563
564 /* Version 2 only */
566 {
567 public:
569 : Entry(AppleSingleDouble::ID_AFPShortName)
570 {
571 }
572 /* TODO - this is a stub */
573
574 offset_t ImageSize() const override;
575
576 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
577
579 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
580
581 void Dump(Dumper::Dumper& dump) const override;
582 };
583
584 /* Version 2 only */
586 {
587 public:
589 : Entry(AppleSingleDouble::ID_AFPFileInfo)
590 {
591 }
592 /* TODO - this is a stub */
593
594 offset_t ImageSize() const override;
595
596 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
597
599 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
600
601 void Dump(Dumper::Dumper& dump) const override;
602 };
603
604 /* Version 2 only */
606 {
607 public:
609 : Entry(AppleSingleDouble::ID_AFPDirectoryID)
610 {
611 }
612 /* TODO - this is a stub */
613
614 offset_t ImageSize() const override;
615
616 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
617
619 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
620
621 void Dump(Dumper::Dumper& dump) const override;
622 };
623
628 {
629 public:
630 std::shared_ptr<AppleSingleDouble> apple_single;
631
632 enum version_t
633 {
634 /* assigning values to the first two does not matter, because we don't generate the fields that hold them */
635 MACBIN1,
636 MACBIN1_GETINFO, /* extension */
637 MACBIN2 = 129,
638 MACBIN3 = 130,
639 };
640 version_t version, minimum_version;
641
642 uint16_t secondary_header_size = 0; /* TODO */
643 mutable uint16_t crc = 0;
644
645 uint8_t attributes = 0;
646 ::Timestamp<Macintosh_clock> creation = { }; /* TODO: what is the actual epoch? */
647 ::Timestamp<Macintosh_clock> modification = { };
648
649 /* only used during parsing */
650 uint32_t data_fork_length = 0;
651 uint32_t resource_fork_length = 0;
652 uint16_t comment_length = 0;
653
654 std::string generated_file_name;
655
656 MacBinary(version_t version = MACBIN3)
657 : apple_single(std::make_shared<AppleSingleDouble>(AppleSingleDouble::DOUBLE)), version(version), minimum_version(version <= MACBIN2 ? version : MACBIN2)
658 {
659 }
660
661 MacBinary(version_t version, version_t minimum_version)
662 : apple_single(std::make_shared<AppleSingleDouble>(AppleSingleDouble::DOUBLE)), version(version), minimum_version(version < minimum_version ? version : minimum_version)
663 {
664 }
665
666 explicit MacBinary(std::shared_ptr<AppleSingleDouble> apple, version_t version, version_t minimum_version)
667 : apple_single(apple), version(version), minimum_version(version < minimum_version ? version : minimum_version)
668 {
669 }
670
671 /* CRC16-CCITT */
672 static uint16_t crc_step[256];
673
674 void CRC_Initialize() const;
675
676 void CRC_Step(uint8_t byte = 0) const;
677
678 void Skip(const std::shared_ptr<Linker::Writer>& wr, size_t count) const;
679
680 void WriteData(const std::shared_ptr<Linker::Writer>& wr, size_t count, const void * data) const;
681
682 void WriteData(const std::shared_ptr<Linker::Writer>& wr, size_t count, std::string text) const;
683
684 void WriteWord(const std::shared_ptr<Linker::Writer>& wr, size_t bytes, uint64_t value) const;
685
686 template <typename Clock>
687 void WriteTimestamp(const std::shared_ptr<Linker::Writer>& wr, Timestamp<Clock> timestamp) const
688 {
689 WriteWord(wr, sizeof(typename Clock::rep), Clock::to_ticks(timestamp));
690 }
691
692 void ReadHeader(const std::shared_ptr<Linker::Reader>& rd);
693 void WriteHeader(const std::shared_ptr<Linker::Writer>& wr) const;
694
695 void CalculateOffsets();
696
697 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
698
700 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
701
702 void Dump(Dumper::Dumper& dump) const override;
703 };
704
709 {
710 protected:
728
743
744 public:
747
750
751// TODO: move?
752 /* the ProDOS file type */
753 enum file_type_t : uint8_t
754 {
755 FILE_TYPE_BIN = 0x06,
756 FILE_TYPE_SOS = 0x0C,
757 FILE_TYPE_S16 = 0xB3,
758 FILE_TYPE_EXE = 0xB5,
759 FILE_TYPE_SYS = 0xFF,
760 };
761
762 unsigned apple_single_double_version = 2;
763 /* Only relevant for version 1 */
764 Apple::AppleSingleDouble::hfs_type home_file_system = Apple::AppleSingleDouble::HFS_UNDEFINED;
765
766 MacBinary::version_t macbinary_version = MacBinary::MACBIN3, macbinary_minimum_version = MacBinary::MACBIN2;
767
768 void SetAppleSingleDoubleVersion(offset_t version);
769
770 protected:
773 {
774 }
775
776 virtual bool SupportedSupplementaryFormat(produce_format_t produce) = 0;
777 public:
778 bool AddSupplementaryOutputFormat(std::string subformat) override;
779
780 protected:
793
795 std::shared_ptr<Apple::AppleSingleDouble> apple_single;
797 std::shared_ptr<MacBinary> mac_binary;
798
799 void CalculateValues() override;
800
802 virtual void OnContainerCreated();
804 virtual void OnReadFile(const std::shared_ptr<Linker::Reader>& rd);
806 virtual offset_t OnWriteFile(const std::shared_ptr<Linker::Writer>& wr) const;
808 virtual void OnDump(Dumper::Dumper& dump) const;
809
810 protected:
812 void GenerateFiles(std::string filename, std::shared_ptr<Contents> data_fork, std::shared_ptr<Contents> resource_fork, uint8_t file_type, uint16_t auxiliary_file_type);
813
814 public:
815 void ReadFile(const std::shared_ptr<Linker::Reader>& rd) override;
816
818 offset_t WriteFile(const std::shared_ptr<Linker::Writer>& wr) const override;
819
820 void Dump(Dumper::Dumper& dump) const override;
821 };
822}
823
824#endif /* APPLE_H */
Definition apple.h:606
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1842
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1847
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1853
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1837
Definition apple.h:586
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1824
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1819
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1830
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1814
Definition apple.h:566
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1791
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1807
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1796
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1801
Definition apple.h:66
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &out) const override=0
Stores data in memory to file.
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override=0
Loads file into memory.
offset_t ImageSize() const override=0
Retrieves the offset of the byte after the last one belonging to this format from the first one.
void Dump(Dumper::Dumper &dump) const override=0
Display file contents in a nice manner.
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &out) const override
Stores data in memory to file.
Definition apple.cc:253
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:215
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:266
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:220
AppleSingle & AppleDouble.
Definition apple.h:30
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:54
Timestamp GetCreationDate()
Retrieves creation date field and creates it if it does not exist.
Definition apple.cc:547
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:951
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:17
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:919
Timestamp GetModificationDate()
Retrieves modification date field and creates it if it does not exist.
Definition apple.cc:651
uint32_t ReadMacintoshAttributes()
Retrieves Macintosh attributes field if it exists.
Definition apple.cc:796
uint32_t GetMacintoshAttributes()
Retrieves Macintosh attributes field and creates it if it does not exist.
Definition apple.cc:780
std::optional< Timestamp > ReadCreationDate()
Retrieves creation date field if it exists.
Definition apple.cc:582
std::optional< Timestamp > ReadModificationDate()
Retrieves modification date field if it exists.
Definition apple.cc:692
Definition apple.h:430
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1239
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1234
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1229
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1250
Definition apple.h:405
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1209
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1200
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1219
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1205
Definition apple.h:383
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1168
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1180
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1173
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1189
Definition apple.h:329
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1108
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1099
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1119
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1094
Definition apple.h:355
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1135
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1145
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1157
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1130
Definition apple.h:314
Definition apple.h:459
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1305
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1287
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1282
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1325
Definition apple.h:275
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1048
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1064
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &out) const override
Stores data in memory to file.
Definition apple.cc:1058
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1053
Definition apple.h:294
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1071
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1076
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1087
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &out) const override
Stores data in memory to file.
Definition apple.cc:1081
Definition apple.h:544
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1769
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1763
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1758
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1777
MacBinary is an alternative format to AppleSingle for representing a Macintosh file on a non-Macintos...
Definition apple.h:628
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:2103
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:2162
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:2132
Definition apple.h:497
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1359
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1370
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1378
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1364
This is not actually a file format, but an interface to permit generating multiple binary outputs for...
Definition apple.h:709
std::shared_ptr< MacBinary > mac_binary
Container for MacBinary (Macintosh only)
Definition apple.h:797
void GenerateFiles(std::string filename, std::shared_ptr< Contents > data_fork, std::shared_ptr< Contents > resource_fork, uint8_t file_type, uint16_t auxiliary_file_type)
Tasked to create all the requested files.
Definition apple.cc:2316
virtual offset_t OnWriteFile(const std::shared_ptr< Linker::Writer > &wr) const
Called if there is no container allocated.
Definition apple.cc:2305
produce_format_t
Represents what additional files should be generated.
Definition apple.h:731
@ PRODUCE_NAPS_SUFFIX
NuLib2 attribute preservation string suffix, such as #06xxxx (Apple II, III, IIgs only)
Definition apple.h:741
@ PRODUCE_FINDER_INFO
Places a Finder Information file under the directory .finf (Macintosh only)
Definition apple.h:735
@ PRODUCE_MAC_BINARY
Creates a MacBinary with the .mbin extension (Macintosh only)
Definition apple.h:739
@ PRODUCE_RESOURCE_FORK
Places a GS/OS format resource file under the directory .rsrc.
Definition apple.h:733
@ PRODUCE_APPLE_DOUBLE
Creates an AppleDouble binary with the '' prefix.
Definition apple.h:737
target_format_t target
Format of "filename".
Definition apple.h:746
container_format_t
Format of container stored in memory.
Definition apple.h:783
@ CONTAINER_APPLE_SINGLE
Use an AppleSingle container.
Definition apple.h:787
@ CONTAINER_MAC_BINARY
Use a MacBinary container as well as an AppleSingle container (Macintosh only)
Definition apple.h:789
@ CONTAINER_NONE
No container is stored.
Definition apple.h:785
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:2556
container_format_t container
The container type used to store metainformation while processing.
Definition apple.h:792
target_format_t
Represents the file type of the main file.
Definition apple.h:713
@ TARGET_DATA_FORK
Main file is a data fork, typically empty.
Definition apple.h:717
@ TARGET_RESOURCE_FORK
Main file is a resource fork.
Definition apple.h:719
@ TARGET_APPLE_SINGLE
Main file is an AppleSingle.
Definition apple.h:721
@ TARGET_NONE
Do not generate main file.
Definition apple.h:715
@ TARGET_APPLE_DOUBLE
Main file is an AppleDouble.
Definition apple.h:723
@ TARGET_MAC_BINARY
Main file as a MacBinary (Macintosh only)
Definition apple.h:725
produce_format_t produce
Bitset of other files to produce.
Definition apple.h:749
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:2492
bool AddSupplementaryOutputFormat(std::string subformat) override
If the output format actually drives multiple output formats (resource file, apple double,...
Definition apple.cc:2223
virtual void OnDump(Dumper::Dumper &dump) const
Called if there is no container allocated.
Definition apple.cc:2311
std::shared_ptr< Apple::AppleSingleDouble > apple_single
Container for all the necessary additional information.
Definition apple.h:795
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:2541
virtual void OnReadFile(const std::shared_ptr< Linker::Reader > &rd)
Called if there is no container allocated.
Definition apple.cc:2300
virtual void OnContainerCreated()
Called after the container is created.
Definition apple.cc:2294
void CalculateValues() override
Intermediate step between processing module and generating output file to set up headers and manageme...
Definition apple.cc:2296
Definition apple.h:518
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1396
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1419
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1401
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1409
Definition apple.h:255
offset_t WriteFile(const std::shared_ptr< Linker::Writer > &wr) const override
Stores data in memory to file.
Definition apple.cc:1033
offset_t ImageSize() const override
Retrieves the offset of the byte after the last one belonging to this format from the first one.
Definition apple.cc:1023
void ReadFile(const std::shared_ptr< Linker::Reader > &rd) override
Loads file into memory.
Definition apple.cc:1028
void Dump(Dumper::Dumper &dump) const override
Display file contents in a nice manner.
Definition apple.cc:1041
An abstract interface that separates structure and presentation of the data inside a file.
Definition dumper.h:1009
A record that represents a region within the file.
Definition dumper.h:902
A class to encode a general file format.
Definition format.h:29
offset_t WriteFile(const std::shared_ptr< Writer > &wr) const override=0
Stores data in memory to file.
A class that provides a general interface to setting up generation for a format.
Definition format.h:69
Definition apple.h:462
A static class that encodes a specific timestamp format.
Definition common.h:210