Exclude the slash at the beginning of each file for FS_ListFilteredFiles

This commit is contained in:
smallmodel 2024-12-01 20:33:51 +01:00
parent 4f699f3b58
commit b5a73384d3
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
2 changed files with 9 additions and 2 deletions

View file

@ -2367,6 +2367,9 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, const char
}
pathLength = strlen( path );
if ( path[pathLength-1] == '\\' || path[pathLength-1] == '/' ) {
pathLength--;
}
extensionLength = strlen( extension );
nfiles = 0;
FS_ReturnPath(path, zpath, &pathDepth);
@ -2451,7 +2454,11 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, const char
nfiles = FS_AddFileToList(zpath, list, nfiles);
}
else {
nfiles = FS_AddFileToList(name + pathLength, list, nfiles);
temp = pathLength;
if (pathLength) {
temp++; // include the '/'
}
nfiles = FS_AddFileToList(name + temp, list, nfiles);
}
}
}

View file

@ -3656,7 +3656,7 @@ static void ScanAndLoadShaderFiles( void )
long sum = 0;
// scan for shader files
shaderFiles = ri.FS_ListFiles("scripts/", ".shader", &numShaders);
shaderFiles = ri.FS_ListFiles("scripts", ".shader", &numShaders);
if (!shaderFiles || !numShaders)
{