mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 11:35:05 +08:00
filesystem: replace va function calls.
This commit is contained in:
committed by
Alibek Omarov
parent
daaaa324bd
commit
34160151a4
@@ -42,12 +42,15 @@ static inline qboolean IsIdGamedir( const char *id )
|
||||
!Q_strcmp( id, "GAMEDOWNLOAD" );
|
||||
}
|
||||
|
||||
static inline const char *IdToDir( const char *id )
|
||||
static inline const char *IdToDir( char *dir, size_t size, const char *id )
|
||||
{
|
||||
if( !Q_strcmp( id, "GAME" ))
|
||||
return GI->gamefolder;
|
||||
else if( !Q_strcmp( id, "GAMEDOWNLOAD" ))
|
||||
return va( "%s/downloaded", GI->gamefolder );
|
||||
{
|
||||
Q_snprintf( dir, size, "%s/downloaded", GI->gamefolder );
|
||||
return dir;
|
||||
}
|
||||
else if( !Q_strcmp( id, "GAMECONFIG" ))
|
||||
return fs_writepath->filename; // full path here so it's totally our write allowed directory
|
||||
else if( !Q_strcmp( id, "PLATFORM" ))
|
||||
@@ -145,7 +148,10 @@ public:
|
||||
|
||||
void CreateDirHierarchy( const char *path, const char *id ) override
|
||||
{
|
||||
FS_CreatePath( va( "%s/%s", IdToDir( id ), path )); // FS_CreatePath is aware of slashes
|
||||
char dir[MAX_VA_STRING], fullpath[MAX_VA_STRING];
|
||||
|
||||
Q_snprintf( fullpath, sizeof( fullpath ), "%s/%s", IdToDir( dir, sizeof( dir ), id ), path );
|
||||
FS_CreatePath( fullpath ); // FS_CreatePath is aware of slashes
|
||||
}
|
||||
|
||||
bool FileExists( const char *path ) override
|
||||
@@ -365,7 +371,6 @@ public:
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
const char *fullpath = FS_GetDiskPath( p, false );
|
||||
if( !fullpath )
|
||||
return NULL;
|
||||
@@ -449,10 +454,12 @@ public:
|
||||
|
||||
bool AddPackFile( const char *path, const char *id ) override
|
||||
{
|
||||
char *p = va( "%s/%s", IdToDir( id ), path );
|
||||
CopyAndFixSlashes( p, path );
|
||||
char dir[MAX_VA_STRING], fullpath[MAX_VA_STRING];
|
||||
|
||||
return !!FS_AddPak_Fullpath( p, NULL, FS_CUSTOM_PATH );
|
||||
Q_snprintf( fullpath, sizeof( fullpath ), "%s/%s", IdToDir( dir, sizeof( dir ), id ), path );
|
||||
CopyAndFixSlashes( fullpath, path );
|
||||
|
||||
return !!FS_AddPak_Fullpath( fullpath, NULL, FS_CUSTOM_PATH );
|
||||
}
|
||||
|
||||
FileHandle_t OpenFromCacheForRead( const char *path , const char *mode, const char *id ) override
|
||||
|
||||
Reference in New Issue
Block a user