mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Fix filename case sensitivity on Linux
This fixes #334 where some sounds wouldn't play because some scripts reference sounds without respecting the case
This commit is contained in:
parent
1d60405eaa
commit
5b80ea20c7
1 changed files with 47 additions and 10 deletions
|
@ -33,6 +33,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "qcommon.h"
|
||||
#include "unzip.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <sys/types.h>
|
||||
# include <dirent.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
|
@ -522,17 +527,51 @@ check_filecase
|
|||
====================
|
||||
*/
|
||||
static int check_filecase( char *Path ) {
|
||||
/*
|
||||
int retval;
|
||||
int retval;
|
||||
|
||||
#ifdef _WIN32
|
||||
retval = 0;
|
||||
#else
|
||||
char *ptr;
|
||||
char *filename;
|
||||
char *basedir;
|
||||
DIR* dir;
|
||||
|
||||
// of course there is no portable way to open a dir in Linux or Windows
|
||||
// DAMNIT
|
||||
// FIXME: stub
|
||||
*/
|
||||
return 0;
|
||||
retval = 0;
|
||||
ptr = strrchr(Path, '/');
|
||||
filename = Path;
|
||||
|
||||
if (ptr) {
|
||||
filename = ptr + 1;
|
||||
}
|
||||
|
||||
basedir = ".";
|
||||
if (ptr)
|
||||
{
|
||||
basedir = Path;
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
dir = opendir(basedir);
|
||||
if (dir)
|
||||
{
|
||||
dirent* ent;
|
||||
|
||||
for (ent = readdir(dir); ent && !retval; ent = readdir(dir)) {
|
||||
if (!Q_stricmp(ent->d_name, filename)) {
|
||||
strcpy(filename, ent->d_name);
|
||||
retval = 1;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
if (ptr) {
|
||||
*ptr = '/';
|
||||
}
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -564,9 +603,7 @@ void FS_CorrectCase( char *path ) {
|
|||
*ptr = 0;
|
||||
}
|
||||
|
||||
getOut = access( path, 0 );
|
||||
|
||||
if( getOut ) {
|
||||
if( access(path, 0) ) {
|
||||
getOut = !check_filecase( path );
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue