mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-18 19:10:37 +00:00
engine: filesystem: fixed FS_Search algorithm for ZIP files (fix #796)
This commit is contained in:
parent
cd2720ba81
commit
65d624140e
@ -3658,6 +3658,7 @@ search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
|
||||
searchpath_t *searchpath;
|
||||
pack_t *pak;
|
||||
wfile_t *wad;
|
||||
zip_t *zip;
|
||||
int i, basepathlength, numfiles, numchars;
|
||||
int resultlistindex, dirlistindex;
|
||||
const char *slash, *backslash, *colon, *separator;
|
||||
@ -3725,6 +3726,42 @@ search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly )
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( searchpath->zip )
|
||||
{
|
||||
zip = searchpath->zip;
|
||||
for( i = 0; i < zip->numfiles; i++ )
|
||||
{
|
||||
Q_strncpy( temp, zip->files[i].name, sizeof(temp) );
|
||||
while( temp[0] )
|
||||
{
|
||||
if( matchpattern( temp, (char *)pattern, true ))
|
||||
{
|
||||
for( resultlistindex = 0; resultlistindex < resultlist.numstrings; resultlistindex++ )
|
||||
{
|
||||
if( !Q_strcmp( resultlist.strings[resultlistindex], temp ))
|
||||
break;
|
||||
}
|
||||
|
||||
if( resultlistindex == resultlist.numstrings )
|
||||
stringlistappend( &resultlist, temp );
|
||||
}
|
||||
|
||||
// strip off one path element at a time until empty
|
||||
// this way directories are added to the listing if they match the pattern
|
||||
slash = Q_strrchr( temp, '/' );
|
||||
backslash = Q_strrchr( temp, '\\' );
|
||||
colon = Q_strrchr( temp, ':' );
|
||||
separator = temp;
|
||||
if( separator < slash )
|
||||
separator = slash;
|
||||
if( separator < backslash )
|
||||
separator = backslash;
|
||||
if( separator < colon )
|
||||
separator = colon;
|
||||
*((char *)separator) = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( searchpath->wad )
|
||||
{
|
||||
string wadpattern, wadname, temp2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user