| 30 | } |
| 31 | |
| 32 | bool LfdArchive::open(const char *archivePath) |
| 33 | { |
| 34 | m_archiveOpen = m_file.open(archivePath, Stream::MODE_READ); |
| 35 | m_curFile = -1; |
| 36 | m_fileOffset = 0; |
| 37 | if (!m_archiveOpen) { return false; } |
| 38 | |
| 39 | // Read the directory. |
| 40 | LFD_Entry_t root, entry; |
| 41 | m_file.readBuffer(&root, sizeof(LFD_Entry_t)); |
| 42 | m_fileList.MASTERN = root.LENGTH / sizeof(LFD_Entry_t); |
| 43 | m_fileList.entries = new LFD_EntryFinal_t[m_fileList.MASTERN]; |
| 44 | |
| 45 | s32 IX = sizeof(LFD_Entry_t) + root.LENGTH; |
| 46 | for (u32 i = 0; i < m_fileList.MASTERN; i++) |
| 47 | { |
| 48 | m_file.readBuffer(&entry, sizeof(LFD_Entry_t)); |
| 49 | |
| 50 | char name[9] = { 0 }; |
| 51 | char ext[5] = { 0 }; |
| 52 | memcpy(name, entry.NAME, 8); |
| 53 | memcpy(ext, entry.TYPE, 4); |
| 54 | ext[4] = 0; |
| 55 | |
| 56 | sprintf(m_fileList.entries[i].NAME, "%s.%s", name, ext); |
| 57 | m_fileList.entries[i].LENGTH = entry.LENGTH; |
| 58 | m_fileList.entries[i].IX = IX + sizeof(LFD_Entry_t); |
| 59 | |
| 60 | IX += sizeof(LFD_Entry_t) + entry.LENGTH; |
| 61 | } |
| 62 | |
| 63 | strcpy(m_archivePath, archivePath); |
| 64 | m_file.close(); |
| 65 | |
| 66 | return true; |
| 67 | } |
| 68 | |
| 69 | void LfdArchive::close() |
| 70 | { |
no test coverage detected