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

Method open

TheForceEngine/TFE_Archive/zipArchive.cpp:46–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46bool ZipArchive::open(const char *archivePath)
47{
48 m_curFile = INVALID_FILE;
49 m_entryCount = 0;
50 m_fileOffset = 0;
51 m_tempBuffer = nullptr;
52 m_tempBufferSize = 0;
53
54 struct zip_t* zip = zip_open(archivePath, 0, 'r');
55 if (!zip)
56 {
57 TFE_System::logWrite(LOG_ERROR, "zipArchive", "Cannot open Zip Archive '%s'", archivePath);
58 return false;
59 }
60
61 // Read the directory.
62 m_entryCount = zip_total_entries(zip);
63 if (m_entryCount <= 0)
64 {
65 TFE_System::logWrite(LOG_ERROR, "zipArchive", "Zip Archive '%s' is empty.", archivePath);
66 zip_close(zip);
67 return false;
68 }
69 m_entries = new ZipEntry[m_entryCount];
70
71 for (s32 i = 0; i < m_entryCount; i++)
72 {
73 if (zip_entry_openbyindex(zip, i) != 0)
74 {
75 TFE_System::logWrite(LOG_ERROR, "zipArchive", "Cannot read entry '%d' from archive '%s'", i, archivePath);
76 zip_close(zip);
77 return false;
78 }
79
80 m_entries[i].isDir = (zip_entry_isdir(zip) == 1);
81 m_entries[i].name = zip_entry_name(zip);
82 m_entries[i].length = (size_t)zip_entry_size(zip);
83 zip_entry_close(zip);
84 }
85 zip_close(zip);
86
87 strcpy(m_archivePath, archivePath);
88 m_fileHandle = nullptr;
89
90 return true;
91}
92
93void ZipArchive::close()
94{

Callers 15

logOpenFunction · 0.45
loadMessagesFunction · 0.45
getArchiveMethod · 0.45
writeFunction · 0.45
loadFrameHdFunction · 0.45
getFrameFunction · 0.45
loadWaxHdFunction · 0.45
getWaxFunction · 0.45
getFunction · 0.45
getFunction · 0.45
loadSoundFileFunction · 0.45

Calls 9

zip_openFunction · 0.85
logWriteFunction · 0.85
zip_total_entriesFunction · 0.85
zip_closeFunction · 0.85
zip_entry_openbyindexFunction · 0.85
zip_entry_isdirFunction · 0.85
zip_entry_nameFunction · 0.85
zip_entry_sizeFunction · 0.85
zip_entry_closeFunction · 0.85

Tested by

no test coverage detected