mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-12-12 13:12:07 +00:00
Fix Windows file list extension check
Windows' Sys_ListFiles would add files that contain the extension anywhere, not only at the end of the file name. Example: "word.pk3omghacks" use to be loaded as a pk3 file.
This commit is contained in:
parent
b152cf1423
commit
993b838f27
1 changed files with 11 additions and 0 deletions
|
@ -410,6 +410,7 @@ char **Sys_ListFiles( const char *directory, const char *extension, char *filter
|
|||
intptr_t findhandle;
|
||||
int flag;
|
||||
int i;
|
||||
int extLen;
|
||||
|
||||
if (filter) {
|
||||
|
||||
|
@ -443,6 +444,8 @@ char **Sys_ListFiles( const char *directory, const char *extension, char *filter
|
|||
flag = _A_SUBDIR;
|
||||
}
|
||||
|
||||
extLen = strlen( extension );
|
||||
|
||||
Com_sprintf( search, sizeof(search), "%s\\*%s", directory, extension );
|
||||
|
||||
// search
|
||||
|
@ -456,6 +459,14 @@ char **Sys_ListFiles( const char *directory, const char *extension, char *filter
|
|||
|
||||
do {
|
||||
if ( (!wantsubs && flag ^ ( findinfo.attrib & _A_SUBDIR )) || (wantsubs && findinfo.attrib & _A_SUBDIR) ) {
|
||||
if (*extension) {
|
||||
if ( strlen( findinfo.name ) < extLen ||
|
||||
Q_stricmp(
|
||||
findinfo.name + strlen( findinfo.name ) - extLen,
|
||||
extension ) ) {
|
||||
continue; // didn't match
|
||||
}
|
||||
}
|
||||
if ( nfiles == MAX_FOUND_FILES - 1 ) {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue