@@ -1984,20 +1984,21 @@ FS_ToLowerCase
1984
1984
Function to set all characters of path lowercase
1985
1985
====================
1986
1986
*/
1987
- char * FS_ToLowerCase ( const char * path )
1987
+ static char * FS_ToLowerCase ( const char * path )
1988
1988
{
1989
- if (path ) {
1990
- char * result = malloc (strlen (path ) + 1 );
1991
- int i = 0 ;
1992
- while ( path [i ] )
1993
- {
1994
- result [i ] = tolower ( path [i ] );
1995
- ++ i ;
1996
- }
1997
- result [i ] = '\0' ;
1998
- return result ;
1989
+ static char path2 [MAX_SYSPATH ];
1990
+ int i ;
1991
+
1992
+ ASSERT ( path );
1993
+
1994
+ for ( i = 0 ; path [i ]; i ++ )
1995
+ {
1996
+ path2 [i ] = Q_tolower ( path [i ] );
1999
1997
}
2000
- return NULL ;
1998
+
1999
+ path2 [i ] = 0 ;
2000
+
2001
+ return path2 ;
2001
2002
}
2002
2003
2003
2004
/*
@@ -2753,22 +2754,23 @@ byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamediro
2753
2754
2754
2755
file = FS_Open ( path , "rb" , gamedironly );
2755
2756
2757
+ #ifndef _WIN32
2756
2758
if ( !file )
2757
2759
{
2758
2760
// Try to open this file with lowered path
2759
- char * loweredPath = FS_ToLowerCase ( path );
2760
- file = FS_Open ( loweredPath , "rb" , gamedironly );
2761
- free (loweredPath );
2762
- if ( !file )
2763
- {
2764
- // Now it truly doesn't exist in file system
2765
- buf = W_LoadFile ( path , & filesize , gamedironly );
2761
+ file = FS_Open ( FS_ToLowerCase ( path ), "rb" , gamedironly );
2762
+ }
2763
+ #endif // _WIN32
2764
+
2765
+ if ( !file )
2766
+ {
2767
+ // Now it truly doesn't exist in file system
2768
+ buf = W_LoadFile ( path , & filesize , gamedironly );
2766
2769
2767
- if ( filesizeptr )
2768
- * filesizeptr = filesize ;
2770
+ if ( filesizeptr )
2771
+ * filesizeptr = filesize ;
2769
2772
2770
- return buf ;
2771
- }
2773
+ return buf ;
2772
2774
}
2773
2775
2774
2776
// Try to load
@@ -2800,17 +2802,17 @@ byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr )
2800
2802
2801
2803
file = FS_SysOpen ( path , "rb" );
2802
2804
2805
+ #ifndef _WIN32
2803
2806
if ( !file )
2804
2807
{
2805
2808
// Try to open this file with lowered path
2806
- char * loweredPath = FS_ToLowerCase ( path );
2807
- file = FS_SysOpen ( loweredPath , "rb" );
2808
- free (loweredPath );
2809
- if ( !file )
2810
- {
2811
- return NULL ;
2812
- }
2809
+ file = FS_SysOpen ( FS_ToLowerCase ( path ), "rb" );
2813
2810
}
2811
+ #endif // _WIN32
2812
+
2813
+ if ( !file )
2814
+ return NULL ;
2815
+
2814
2816
2815
2817
// Try to load
2816
2818
filesize = file -> real_length ;
@@ -2836,12 +2838,10 @@ file_t *FS_OpenFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedi
2836
2838
{
2837
2839
file_t * file = FS_Open ( path , "rb" , gamedironly );
2838
2840
2841
+ #ifndef _WIN32
2839
2842
if ( !file )
2840
- {
2841
- char * loweredPath = FS_ToLowerCase ( path );
2842
- file = FS_Open ( loweredPath , "rb" , gamedironly );
2843
- free (loweredPath );
2844
- }
2843
+ file = FS_Open ( FS_ToLowerCase ( path ), "rb" , gamedironly );
2844
+ #endif // _WIN32
2845
2845
2846
2846
if ( filesizeptr )
2847
2847
{
0 commit comments