filesystem: try to fix case of library filename in FindLibrary

This commit is contained in:
Alibek Omarov 2023-07-22 07:04:26 +03:00
parent e7c41759fb
commit 1bfc6e6705
1 changed files with 12 additions and 6 deletions

View File

@ -1261,6 +1261,7 @@ search for library, assume index is valid
*/ */
static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dllinfo_t *dllInfo ) static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dllinfo_t *dllInfo )
{ {
string fixedname;
searchpath_t *search; searchpath_t *search;
int index, start = 0, i, len; 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 // replace all backward slashes
len = Q_strlen( dllname ); len = Q_strlen( dllname );
for( i = 0; i < len; i++ ) for( i = 0; i < len; i++ )
{ {
if( dllname[i+start] == '\\' ) dllInfo->shortPath[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 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; fs_ext_path = false;
// trying check also 'bin' folder for indirect paths // trying check also 'bin' folder for indirect paths
Q_strncpy( dllInfo->shortPath, dllname, sizeof( dllInfo->shortPath )); search = FS_FindFile( dllname, &index, fixedname, sizeof( fixedname ), false );
search = FS_FindFile( dllInfo->shortPath, &index, NULL, 0, false ); if( !search )
if( !search ) return false; // unable to find return false; // unable to find
Q_strncpy( dllInfo->shortPath, fixedname, sizeof( dllInfo->shortPath ));
} }
dllInfo->encrypted = FS_CheckForCrypt( dllInfo->shortPath ); dllInfo->encrypted = FS_CheckForCrypt( dllInfo->shortPath );