MCPcopy Create free account
hub / github.com/assaultcube/AC / fixzipname

Function fixzipname

source/src/zip.cpp:489–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

487}
488
489const char *fixzipname(char *name) // check, if valid path + filename, based on mods/, return NULL if invalid
490{
491 string tmp;
492 unixpath(name); // changes "name"!
493 filtertext(tmp, name, FTXT__MEDIAFILEPATH);
494 const char *bp = behindpath(tmp), *pd = parentdir(tmp);
495 static defformatstring(pname)("%s%s%s%s", pd, bp != tmp ? "/" : "", !strncmp("###", behindpath(name), 3) ? "###" : "", bp);
496 if(strlen(name) > 40 || strchr(name, '.') || strcmp(pname, name) || *name == '/') return NULL; // illegal filename
497 formatstring(pname)("mods/%s.zip", name);
498 return path(pname);
499}
500
501bool validzipmodname(char *name) // check for valid _downloadable_ zip mod name (no '#' allowed), also changes backslashes to slashes
502{

Callers 7

validzipmodnameFunction · 0.85
addzipmodFunction · 0.85
zipmodremoveFunction · 0.85
loopvFunction · 0.85
zipmodgetdescFunction · 0.85
zipmodgetfilesFunction · 0.85
zipmodgetrevisionFunction · 0.85

Calls 5

unixpathFunction · 0.85
filtertextFunction · 0.85
behindpathFunction · 0.85
parentdirFunction · 0.85
pathFunction · 0.85

Tested by

no test coverage detected