MCPcopy Index your code
hub / github.com/assaultcube/AC / mountzip

Function mountzip

source/src/zip.cpp:400–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

398static hashtable<const char *, memfile> memfiles; // table of all memfiles
399
400static void mountzip(ziparchive &arch, const char *mountdir, const char *stripdir, bool allowconfig)
401{
402 string mdir = "", fname;
403 if(mountdir)
404 {
405 copystring(mdir, mountdir);
406 if(fixpackagedir(mdir) <= 1) mdir[0] = '\0';
407 }
408 int striplen = stripdir ? (int)strlen(stripdir) : 0;
409
410 loopv(arch.files)
411 { // build full path names - and check them
412 zipfile *zf = &arch.files[i];
413 formatstring(fname)("%s%s", mdir, striplen && !strncmp(zf->name, stripdir, striplen) ? zf->name + striplen : zf->name);
414 path(fname);
415 unixpath(fname);
416 zf->fullname = newstring(fname);
417 zf->location = &arch;
418 filtertext(fname, fname, FTXT__MEDIAFILEPATH);
419 if(strcmp(fname, zf->fullname) || (strncmp("packages/", fname, 9) && (!allowconfig || strncmp("config/", fname, 7))))
420 { // path is not allowed (illegal characters or illegal path)
421#if defined(_DEBUG) && !defined(STANDALONE)
422 clientlogf("mountzip: ignored file %s from zip %s", fname, arch.name);
423#endif
424 DELSTRING(zf->fullname);
425 }
426 else path(zf->fullname);
427 }
428}
429
430static void rebuildzipfilehashtable()
431{

Callers 1

addzipmodFunction · 0.85

Calls 8

copystringFunction · 0.85
fixpackagedirFunction · 0.85
pathFunction · 0.85
unixpathFunction · 0.85
newstringFunction · 0.85
filtertextFunction · 0.85
clientlogfFunction · 0.85
loopvFunction · 0.70

Tested by

no test coverage detected