From 1bfc6e6705a7c35665777736a24d0d0705cb8c5e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 22 Jul 2023 07:04:26 +0300 Subject: [PATCH] filesystem: try to fix case of library filename in FindLibrary --- filesystem/filesystem.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/filesystem/filesystem.c b/filesystem/filesystem.c index 6a083af7..701467d7 100644 --- a/filesystem/filesystem.c +++ b/filesystem/filesystem.c @@ -1261,6 +1261,7 @@ search for library, assume index is valid */ static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dllinfo_t *dllInfo ) { + string fixedname; searchpath_t *search; int index, start = 0, i, len; @@ -1276,7 +1277,6 @@ static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dll // replace all backward slashes len = Q_strlen( dllname ); - for( i = 0; i < len; i++ ) { if( dllname[i+start] == '\\' ) dllInfo->shortPath[i] = '/'; @@ -1286,16 +1286,22 @@ static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dll COM_DefaultExtension( dllInfo->shortPath, "."OS_LIB_EXT, sizeof( dllInfo->shortPath )); // apply ext if forget - search = FS_FindFile( dllInfo->shortPath, &index, NULL, 0, false ); + search = FS_FindFile( dllInfo->shortPath, &index, fixedname, sizeof( fixedname ), false ); - if( !search && !directpath ) + if( search ) + { + Q_strncpy( dllInfo->shortPath, fixedname, sizeof( dllInfo->shortPath )); + } + else if( !directpath ) { fs_ext_path = false; // trying check also 'bin' folder for indirect paths - Q_strncpy( dllInfo->shortPath, dllname, sizeof( dllInfo->shortPath )); - search = FS_FindFile( dllInfo->shortPath, &index, NULL, 0, false ); - if( !search ) return false; // unable to find + search = FS_FindFile( dllname, &index, fixedname, sizeof( fixedname ), false ); + if( !search ) + return false; // unable to find + + Q_strncpy( dllInfo->shortPath, fixedname, sizeof( dllInfo->shortPath )); } dllInfo->encrypted = FS_CheckForCrypt( dllInfo->shortPath );