generalize FixDOSName function and its use
This commit is contained in:
parent
3cbbbaf7e9
commit
8373782b75
|
|
@ -171,8 +171,6 @@ void SetQdirFromPath( const char *path ){
|
|||
len = strlen( BASEDIRNAME );
|
||||
for ( c = path + strlen( path ) - 1 ; c != path ; c-- )
|
||||
{
|
||||
int i;
|
||||
|
||||
if ( !Q_strncasecmp( c, BASEDIRNAME, len ) ) {
|
||||
//
|
||||
//strncpy (qdir, path, c+len+2-path);
|
||||
|
|
@ -188,26 +186,14 @@ void SetQdirFromPath( const char *path ){
|
|||
}
|
||||
strncpy( qdir, path, c + len + count - path );
|
||||
Sys_Printf( "qdir: %s\n", qdir );
|
||||
for ( i = 0; i < (int) strlen( qdir ); i++ )
|
||||
{
|
||||
if ( qdir[i] == '\\' ) {
|
||||
qdir[i] = '/';
|
||||
}
|
||||
}
|
||||
FixDOSName( qdir );
|
||||
|
||||
c += len + count;
|
||||
while ( *c )
|
||||
{
|
||||
if ( *c == '/' || *c == '\\' ) {
|
||||
strncpy( gamedir, path, c + 1 - path );
|
||||
|
||||
for ( i = 0; i < (int) strlen( gamedir ); i++ )
|
||||
{
|
||||
if ( gamedir[i] == '\\' ) {
|
||||
gamedir[i] = '/';
|
||||
}
|
||||
}
|
||||
|
||||
FixDOSName( gamedir );
|
||||
Sys_Printf( "gamedir: %s\n", gamedir );
|
||||
|
||||
if ( !writedir[0] ) {
|
||||
|
|
@ -290,8 +276,6 @@ double I_FloatTime( void ){
|
|||
}
|
||||
|
||||
void Q_getwd( char *out ){
|
||||
int i = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
_getcwd( out, 256 );
|
||||
strcat( out, "\\" );
|
||||
|
|
@ -302,13 +286,7 @@ void Q_getwd( char *out ){
|
|||
}
|
||||
strcat( out, "/" );
|
||||
#endif
|
||||
while ( out[i] != 0 )
|
||||
{
|
||||
if ( out[i] == '\\' ) {
|
||||
out[i] = '/';
|
||||
}
|
||||
i++;
|
||||
}
|
||||
FixDOSName( out );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -120,6 +120,12 @@ void DefaultPath( char *path, const char *basepath );
|
|||
void StripFilename( char *path );
|
||||
void StripExtension( char *path );
|
||||
|
||||
static inline void FixDOSName( char *src ){
|
||||
for ( ; *src; ++src )
|
||||
if ( *src == '\\' )
|
||||
*src = '/';
|
||||
}
|
||||
|
||||
void ExtractFilePath( const char *path, char *dest );
|
||||
void ExtractFileBase( const char *path, char *dest );
|
||||
void ExtractFileExtension( const char *path, char *dest );
|
||||
|
|
|
|||
|
|
@ -86,20 +86,6 @@ static void vfsAddSlash( char *str ){
|
|||
}
|
||||
}
|
||||
|
||||
static void vfsFixDOSName( char *src ){
|
||||
if ( src == NULL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
while ( *src )
|
||||
{
|
||||
if ( *src == '\\' ) {
|
||||
*src = '/';
|
||||
}
|
||||
src++;
|
||||
}
|
||||
}
|
||||
|
||||
//!\todo Define globally or use heap-allocated string.
|
||||
#define NAME_MAX 255
|
||||
|
||||
|
|
@ -138,7 +124,7 @@ static void vfsInitPakFile( const char *filename ){
|
|||
file = (VFS_PAKFILE*)safe_malloc( sizeof( VFS_PAKFILE ) );
|
||||
g_pakFiles = g_slist_append( g_pakFiles, file );
|
||||
|
||||
vfsFixDOSName( filename_inzip );
|
||||
FixDOSName( filename_inzip );
|
||||
g_strdown( filename_inzip );
|
||||
|
||||
file->name = strdup( filename_inzip );
|
||||
|
|
@ -192,7 +178,7 @@ void vfsInitDirectory( const char *path ){
|
|||
|
||||
strncpy( g_strDirs[g_numDirs], path, PATH_MAX );
|
||||
g_strDirs[g_numDirs][PATH_MAX] = 0;
|
||||
vfsFixDOSName( g_strDirs[g_numDirs] );
|
||||
FixDOSName( g_strDirs[g_numDirs] );
|
||||
vfsAddSlash( g_strDirs[g_numDirs] );
|
||||
g_numDirs++;
|
||||
|
||||
|
|
@ -230,7 +216,7 @@ void vfsInitDirectory( const char *path ){
|
|||
}
|
||||
snprintf( g_strDirs[g_numDirs], PATH_MAX, "%s/%s", path, name );
|
||||
g_strDirs[g_numDirs][PATH_MAX] = '\0';
|
||||
vfsFixDOSName( g_strDirs[g_numDirs] );
|
||||
FixDOSName( g_strDirs[g_numDirs] );
|
||||
vfsAddSlash( g_strDirs[g_numDirs] );
|
||||
++g_numDirs;
|
||||
}
|
||||
|
|
@ -340,7 +326,7 @@ int vfsGetFileCount( const char *filename ){
|
|||
GSList *lst;
|
||||
|
||||
strcpy( fixed, filename );
|
||||
vfsFixDOSName( fixed );
|
||||
FixDOSName( fixed );
|
||||
g_strdown( fixed );
|
||||
|
||||
for ( lst = g_pakFiles; lst != NULL; lst = g_slist_next( lst ) )
|
||||
|
|
@ -405,7 +391,7 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
|
|||
|
||||
*bufferptr = NULL;
|
||||
strcpy( fixed, filename );
|
||||
vfsFixDOSName( fixed );
|
||||
FixDOSName( fixed );
|
||||
g_strdown( fixed );
|
||||
|
||||
for ( i = 0; i < g_numDirs; i++ )
|
||||
|
|
@ -499,7 +485,7 @@ qboolean vfsPackFile( const char *filename, const char *packname, const int comp
|
|||
|
||||
byte *bufferptr = NULL;
|
||||
strcpy( fixed, filename );
|
||||
vfsFixDOSName( fixed );
|
||||
FixDOSName( fixed );
|
||||
g_strdown( fixed );
|
||||
|
||||
for ( i = 0; i < g_numDirs; i++ )
|
||||
|
|
|
|||
|
|
@ -31,20 +31,6 @@
|
|||
#include "autopk3.h"
|
||||
|
||||
|
||||
void FixDOSName( char *src ){
|
||||
if ( src == NULL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
while ( *src )
|
||||
{
|
||||
if ( *src == '\\' ) {
|
||||
*src = '/';
|
||||
}
|
||||
src++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Check if newcoming texture is unique and not excluded
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -208,23 +208,6 @@ void LokiInitPaths( char *argv0 ){
|
|||
|
||||
|
||||
|
||||
/*
|
||||
CleanPath() - ydnar
|
||||
cleans a dos path \ -> /
|
||||
*/
|
||||
|
||||
void CleanPath( char *path ){
|
||||
while ( *path )
|
||||
{
|
||||
if ( *path == '\\' ) {
|
||||
*path = '/';
|
||||
}
|
||||
path++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
GetGame() - ydnar
|
||||
gets the game_t based on a -game argument
|
||||
|
|
@ -282,7 +265,7 @@ void AddBasePath( char *path ){
|
|||
/* add it to the list */
|
||||
basePaths[ numBasePaths ] = safe_malloc( strlen( path ) + 1 );
|
||||
strcpy( basePaths[ numBasePaths ], path );
|
||||
CleanPath( basePaths[ numBasePaths ] );
|
||||
FixDOSName( basePaths[ numBasePaths ] );
|
||||
if ( EnginePath[0] == '\0' ) strcpy( EnginePath, basePaths[ numBasePaths ] );
|
||||
numBasePaths++;
|
||||
}
|
||||
|
|
@ -339,7 +322,7 @@ void AddHomeBasePath( char *path ){
|
|||
/* add it to the list */
|
||||
basePaths[ 0 ] = safe_malloc( strlen( temp ) + 1 );
|
||||
strcpy( basePaths[ 0 ], temp );
|
||||
CleanPath( basePaths[ 0 ] );
|
||||
FixDOSName( basePaths[ 0 ] );
|
||||
numBasePaths++;
|
||||
}
|
||||
|
||||
|
|
@ -361,7 +344,7 @@ void AddGamePath( char *path ){
|
|||
/* add it to the list */
|
||||
gamePaths[ numGamePaths ] = safe_malloc( strlen( path ) + 1 );
|
||||
strcpy( gamePaths[ numGamePaths ], path );
|
||||
CleanPath( gamePaths[ numGamePaths ] );
|
||||
FixDOSName( gamePaths[ numGamePaths ] );
|
||||
numGamePaths++;
|
||||
|
||||
/* don't add it if it's already there */
|
||||
|
|
@ -392,7 +375,7 @@ void AddPakPath( char *path ){
|
|||
/* add it to the list */
|
||||
pakPaths[ numPakPaths ] = safe_malloc( strlen( path ) + 1 );
|
||||
strcpy( pakPaths[ numPakPaths ], path );
|
||||
CleanPath( pakPaths[ numPakPaths ] );
|
||||
FixDOSName( pakPaths[ numPakPaths ] );
|
||||
numPakPaths++;
|
||||
}
|
||||
|
||||
|
|
@ -542,7 +525,7 @@ void InitPaths( int *argc, char **argv ){
|
|||
{
|
||||
/* extract the arg */
|
||||
strcpy( temp, argv[ i ] );
|
||||
CleanPath( temp );
|
||||
FixDOSName( temp );
|
||||
len = strlen( temp );
|
||||
Sys_FPrintf( SYS_VRB, "Searching for \"%s\" in \"%s\" (%d)...\n", game->magic, temp, i );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user