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

Function zipmodlist

source/src/zip.cpp:597–624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

595COMMAND(zipmodclear, "");
596
597void zipmodlist(char *which) // "active", "inactive", "all"(default)
598{
599 vector<char> res;
600 if(!strcasecmp(which, "active"))
601 {
602 loopv(archives) cvecprintf(res, "%s ", archives[i]->name);
603 }
604 else
605 {
606 bool inactive = !strcasecmp(which, "inactive");
607 vector<char *> files;
608 listfilesrecursive("mods", files);
609 files.sort(stringsort);
610 loopvrev(files) if(files.inrange(i + 1) && !strcmp(files[i], files[i + 1])) delstring(files.remove(i + 1)); // remove doubles
611 loopv(files)
612 {
613 char *f = files[i];
614 if(!strncmp(f, "mods/", 5) && !strncmp(f + strlen(f) - 4, ".zip", 4))
615 {
616 f += 5;
617 f[strlen(f) - 4] = '\0';
618 if(fixzipname(f) && (!inactive || !findzip(f))) cvecprintf(res, "%s ", f);
619 }
620 }
621 files.deletearrays();
622 }
623 resultcharvector(res, -1);
624}
625COMMAND(zipmodlist, "s");
626
627const char *desctxt = "desc.txt", *previewjpg = "preview.jpg", *modrev = "revision_"; // special files in zip containing description or preview

Callers

nothing calls this directly

Calls 10

cvecprintfFunction · 0.85
listfilesrecursiveFunction · 0.85
delstringFunction · 0.85
resultcharvectorFunction · 0.85
sortMethod · 0.80
inrangeMethod · 0.80
deletearraysMethod · 0.80
loopvFunction · 0.70
loopvrevFunction · 0.70
removeMethod · 0.45

Tested by

no test coverage detected