MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / findZipEntry

Method findZipEntry

Engine/source/core/util/zip/zipArchive.cpp:258–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258ZipArchive::ZipEntry *ZipArchive::findZipEntry(const char *filename)
259{
260 char path[1024];
261 dStrncpy(path, filename, sizeof(path));
262 path[sizeof(path) - 1] = 0;
263
264 for(S32 i = 0;i < dStrlen(path);++i)
265 {
266 if(path[i] == '\\')
267 path[i] = '/';
268 }
269
270 ZipEntry *root = mRoot;
271
272 char *ptr = path, *slash = NULL;
273 do
274 {
275 slash = dStrchr(ptr, '/');
276 if(slash)
277 {
278 // Find the directory
279 *slash = 0;
280
281 // check child dict for new root
282 ZipEntry *newRoot = NULL;
283 if (!root->mChildren.tryGetValue(ptr, newRoot))
284 return NULL;
285
286 root = newRoot;
287
288 ptr = slash + 1;
289 }
290 else
291 {
292 // Find the file
293 ZipEntry* entry = NULL;
294 if (root->mChildren.tryGetValue(ptr, entry))
295 return entry;
296 }
297 } while(slash);
298
299 return NULL;
300}
301
302//-----------------------------------------------------------------------------
303

Callers 2

resolveMethod · 0.80
resolveLooseMethod · 0.80

Calls 4

dStrncpyFunction · 0.85
tryGetValueMethod · 0.80
dStrlenFunction · 0.50
dStrchrFunction · 0.50

Tested by

no test coverage detected