mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-21 19:41:14 +00:00
'fteqcc -x foo.pak foo' now accepts wildcards.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6055 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
9741676e79
commit
aa651c5059
1 changed files with 46 additions and 1 deletions
|
@ -146,6 +146,51 @@ void QCC_Mkdir(const char *path)
|
|||
//unsupported.
|
||||
}
|
||||
#endif
|
||||
|
||||
static char qcc_tolower(char c)
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
return c-'A'+'a';
|
||||
return c;
|
||||
}
|
||||
int qcc_wildcmp(const char *wild, const char *string)
|
||||
{
|
||||
while (*string)
|
||||
{
|
||||
if (*wild == '*')
|
||||
{
|
||||
if (*string == '/' || *string == '\\')
|
||||
{
|
||||
//* terminates if we get a match on the char following it, or if its a \ or / char
|
||||
wild++;
|
||||
continue;
|
||||
}
|
||||
if (qcc_wildcmp(wild+1, string))
|
||||
return true;
|
||||
string++;
|
||||
}
|
||||
else if ((qcc_tolower(*wild) == qcc_tolower(*string)) || (*wild == '?'))
|
||||
{
|
||||
//this char matches
|
||||
wild++;
|
||||
string++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//failure
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
while (*wild == '*')
|
||||
{
|
||||
wild++;
|
||||
}
|
||||
return !*wild;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const char *extractonly;
|
||||
static pbool extractonlyfound;
|
||||
static void QCC_FileExtract(const char *name, const void *compdata, size_t compsize, int method, size_t plainsize)
|
||||
|
@ -161,7 +206,7 @@ static void QCC_FileExtract(const char *name, const void *compdata, size_t comps
|
|||
return;
|
||||
}
|
||||
else
|
||||
if (strcmp(name, extractonly))
|
||||
if (!qcc_wildcmp(extractonly, name))
|
||||
return; //ignore it if its not the one we're going for.
|
||||
}
|
||||
extractonlyfound = true;
|
||||
|
|
Loading…
Reference in a new issue