MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / open

Method open

TheForceEngine/TFE_Archive/lfdArchive.cpp:32–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32bool 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
69void LfdArchive::close()
70{

Callers 2

createMethod · 0.45
openFileMethod · 0.45

Calls 2

readBufferMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected