mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-17 18:40:02 +00:00
filesystem: fix FS_FixFileCase behavior
This commit is contained in:
parent
89807250e5
commit
fcd741e2b8
@ -284,57 +284,63 @@ const char *FS_FixFileCase( const char *path )
|
|||||||
#elif !XASH_WIN32 && !XASH_IOS // assume case insensitive
|
#elif !XASH_WIN32 && !XASH_IOS // assume case insensitive
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
char path2[PATH_MAX], *fname;
|
char dirpath[PATH_MAX], *filename;
|
||||||
|
static char fixedpath[PATH_MAX];
|
||||||
|
|
||||||
if( !fs_caseinsensitive )
|
if( !fs_caseinsensitive )
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
if( path[0] != '/' )
|
if( path[0] != '/' )
|
||||||
Q_snprintf( path2, sizeof( path2 ), "./%s", path );
|
Q_snprintf( dirpath, sizeof( dirpath ), "./%s", path );
|
||||||
else Q_strncpy( path2, path, PATH_MAX );
|
else Q_strncpy( dirpath, path, PATH_MAX );
|
||||||
|
|
||||||
fname = Q_strrchr( path2, '/' );
|
filename = Q_strrchr( dirpath, '/' );
|
||||||
|
|
||||||
if( fname )
|
if( filename )
|
||||||
*fname++ = 0;
|
*filename++ = '\0';
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fname = (char*)path;
|
filename = (char*)path;
|
||||||
Q_strcpy( path2, ".");
|
Q_strcpy( dirpath, ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* android has too slow directory scanning,
|
/* android has too slow directory scanning,
|
||||||
so drop out some not useful cases */
|
so drop out some not useful cases */
|
||||||
if( fname - path2 > 4 )
|
if( filename - dirpath > 4 )
|
||||||
{
|
{
|
||||||
char *point;
|
char *point;
|
||||||
// too many wad textures
|
// too many wad textures
|
||||||
if( !Q_stricmp( fname - 5, ".wad") )
|
if( !Q_stricmp( filename - 5, ".wad") )
|
||||||
return path;
|
return path;
|
||||||
point = Q_strchr( fname, '.' );
|
point = Q_strchr( filename, '.' );
|
||||||
if( point )
|
if( point )
|
||||||
{
|
{
|
||||||
if( !Q_strcmp( point, ".mip") || !Q_strcmp( point, ".dds" ) || !Q_strcmp( point, ".ent" ) )
|
if( !Q_strcmp( point, ".mip") || !Q_strcmp( point, ".dds" ) || !Q_strcmp( point, ".ent" ) )
|
||||||
return path;
|
return path;
|
||||||
if( fname[0] == '{' )
|
if( filename[0] == '{' )
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Con_Reportf( "FS_FixFileCase: %s\n", path );
|
//Con_Reportf( "FS_FixFileCase: %s\n", path );
|
||||||
|
|
||||||
if( !( dir = opendir( path2 ) ) )
|
if( !( dir = opendir( dirpath ) ) )
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
while( ( entry = readdir( dir ) ) )
|
while( ( entry = readdir( dir ) ) )
|
||||||
{
|
{
|
||||||
if( Q_stricmp( entry->d_name, fname ) )
|
if( Q_stricmp( entry->d_name, filename ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
path = va( "%s/%s", path2, entry->d_name );
|
Q_snprintf( fixedpath, sizeof( fixedpath ), "%s/%s", dirpath, entry->d_name );
|
||||||
//Con_Reportf( "FS_FixFileCase: %s %s %s\n", path2, fname, entry->d_name );
|
|
||||||
|
//Con_Reportf( "FS_FixFileCase: %s %s %s\n", dirpath, filename, entry->d_name );
|
||||||
|
|
||||||
|
path = fixedpath;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir( dir );
|
closedir( dir );
|
||||||
#endif
|
#endif
|
||||||
return path;
|
return path;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user