| #include "System.h" | |
| #include "Formatter.h" | |
| Formatter::Formatter(File* file) | |
| { | |
| _file = file; | |
| } | |
| Formatter::~Formatter(void) | |
| { | |
| } | |
| SFXFooter* Formatter::ParseFooter() | |
| { | |
| //navigate and read SFX Footer | |
| if ( false == _file->Seek(_file, - sizeof(SFXFooter), SEEK__END )) | |
| return 0; | |
| SFXFooter* footer = (SFXFooter*)System::SafeAllocMemory(sizeof(SFXFooter)); | |
| UINT packageSize = _file->ReadUINT(_file); | |
| UINT crc32 = _file->ReadUINT(_file); | |
| footer->PackageSize = packageSize; | |
| footer->CRC32 = crc32; | |
| return footer; | |
| } | |
| SFXHeader* Formatter::ParseHeader(void) | |
| { | |
| SFXHeader* header = (SFXHeader*)System::SafeAllocMemory(sizeof(SFXHeader)); | |
| _file->Read(_file,header->Signature,19); | |
| BYTE version = 0; | |
| _file->Read(_file,&version,1); | |
| header->Version = version; | |
| header->numberOfFiles = _file->ReadUINT(_file); | |
| return header; | |
| } | |
| ExecutionInfo* Formatter::ParseExecutionInfo(void) | |
| { | |
| ExecutionInfo* result = (ExecutionInfo*)System::SafeAllocMemory(sizeof(ExecutionInfo)); | |
| result->Flags = _file->ReadUINT(_file); | |
| result->ExecutableStringId = _file->ReadUINT(_file); | |
| result->ArgsStringId = _file->ReadUINT(_file); | |
| return result; | |
| } | |
| FileInformation* Formatter::ParseFileInformationTable(UINT entriesCount) | |
| { | |
| FileInformation* result = (FileInformation*)System::SafeAllocMemory(entriesCount * sizeof(FileInformation)); | |
| for ( int i = 0; i < entriesCount; i ++) | |
| { | |
| UINT fileSize = _file->ReadUINT(_file); | |
| UINT fileName = _file->ReadUINT(_file); | |
| UINT* currStructPointer = (UINT*)(result + i); | |
| *currStructPointer = fileSize; | |
| *(currStructPointer + 1) = fileName; | |
| } | |
| return result; | |
| } |