mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
filesystem: replace COM_CheckString and COM_CheckStringEmpty by COM_StringEmptyOrNULL and COM_StringEmpty
This commit is contained in:
@@ -422,7 +422,7 @@ public:
|
||||
|
||||
bool FullPathToRelativePath( const char *path, char *out ) override
|
||||
{
|
||||
if( !COM_CheckString( path ))
|
||||
if( COM_StringEmptyOrNULL( path ))
|
||||
{
|
||||
*out = 0;
|
||||
return false;
|
||||
|
||||
@@ -300,7 +300,7 @@ qboolean FS_FixFileCase( dir_t *dir, const char *path, char *dst, const size_t l
|
||||
return false;
|
||||
|
||||
// nothing to fix
|
||||
if( !COM_CheckStringEmpty( path ))
|
||||
if( COM_StringEmpty( path ))
|
||||
return true;
|
||||
|
||||
for( prev = path, next = Q_strchrnul( prev, '/' );
|
||||
|
||||
@@ -555,7 +555,7 @@ Return true if the path should be rejected due to one of the following:
|
||||
static int FS_CheckNastyPath( const char *path )
|
||||
{
|
||||
// all: never allow an empty path, as for gamedir it would access the parent directory and a non-gamedir path it is just useless
|
||||
if( !COM_CheckString( path )) return 2;
|
||||
if( COM_StringEmptyOrNULL( path )) return 2;
|
||||
|
||||
if( fs_ext_path ) return 0; // allow any path
|
||||
|
||||
@@ -604,24 +604,24 @@ static qboolean FS_WriteGameInfo( const char *filepath, const gameinfo_t *GameIn
|
||||
|
||||
FS_Printf( f, "// generated by " XASH_ENGINE_NAME " " XASH_VERSION "-%s (%s-%s)\n\n\n", g_buildcommit, Q_buildos(), Q_buildarch() );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->basedir ) )
|
||||
if( !COM_StringEmpty( GameInfo->basedir ))
|
||||
FS_Printf( f, "basedir\t\t\"%s\"\n", GameInfo->basedir );
|
||||
|
||||
// DEPRECATED: gamedir key isn't supported by FWGS fork
|
||||
// but write it anyway to keep compability with original Xash3D
|
||||
if( COM_CheckStringEmpty( GameInfo->gamefolder ) )
|
||||
if( !COM_StringEmpty( GameInfo->gamefolder ))
|
||||
FS_Printf( f, "gamedir\t\t\"%s\"\n", GameInfo->gamefolder );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->falldir ) )
|
||||
if( !COM_StringEmpty( GameInfo->falldir ))
|
||||
FS_Printf( f, "fallback_dir\t\"%s\"\n", GameInfo->falldir );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->title ) )
|
||||
if( !COM_StringEmpty( GameInfo->title ))
|
||||
FS_Printf( f, "title\t\t\"%s\"\n", GameInfo->title );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->startmap ) )
|
||||
if( !COM_StringEmpty( GameInfo->startmap ))
|
||||
FS_Printf( f, "startmap\t\t\"%s\"\n", GameInfo->startmap );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->trainmap ) )
|
||||
if( !COM_StringEmpty( GameInfo->trainmap ))
|
||||
FS_Printf( f, "trainmap\t\t\"%s\"\n", GameInfo->trainmap );
|
||||
|
||||
if( GameInfo->version != 0.0f )
|
||||
@@ -630,31 +630,31 @@ static qboolean FS_WriteGameInfo( const char *filepath, const gameinfo_t *GameIn
|
||||
if( GameInfo->size != 0 )
|
||||
FS_Printf( f, "size\t\t%zu\n", GameInfo->size );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->game_url ) )
|
||||
if( !COM_StringEmpty( GameInfo->game_url ))
|
||||
FS_Printf( f, "url_info\t\t\"%s\"\n", GameInfo->game_url );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->update_url ) )
|
||||
if( !COM_StringEmpty( GameInfo->update_url ))
|
||||
FS_Printf( f, "url_update\t\t\"%s\"\n", GameInfo->update_url );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->type ) )
|
||||
if( !COM_StringEmpty( GameInfo->type ))
|
||||
FS_Printf( f, "type\t\t\"%s\"\n", GameInfo->type );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->date ) )
|
||||
if( !COM_StringEmpty( GameInfo->date ))
|
||||
FS_Printf( f, "date\t\t\"%s\"\n", GameInfo->date );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->dll_path ) )
|
||||
if( !COM_StringEmpty( GameInfo->dll_path ))
|
||||
FS_Printf( f, "dllpath\t\t\"%s\"\n", GameInfo->dll_path );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->game_dll ) )
|
||||
if( !COM_StringEmpty( GameInfo->game_dll ))
|
||||
FS_Printf( f, "gamedll\t\t\"%s\"\n", GameInfo->game_dll );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->game_dll_linux ) )
|
||||
if( !COM_StringEmpty( GameInfo->game_dll_linux ))
|
||||
FS_Printf( f, "gamedll_linux\t\t\"%s\"\n", GameInfo->game_dll_linux );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->game_dll_osx ) )
|
||||
if( !COM_StringEmpty( GameInfo->game_dll_osx ))
|
||||
FS_Printf( f, "gamedll_osx\t\t\"%s\"\n", GameInfo->game_dll_osx );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->iconpath ))
|
||||
if( !COM_StringEmpty( GameInfo->iconpath ))
|
||||
FS_Printf( f, "icon\t\t\"%s\"\n", GameInfo->iconpath );
|
||||
|
||||
switch( GameInfo->gamemode )
|
||||
@@ -663,11 +663,11 @@ static qboolean FS_WriteGameInfo( const char *filepath, const gameinfo_t *GameIn
|
||||
case 2: FS_Print( f, "gamemode\t\t\"multiplayer_only\"\n" ); break;
|
||||
}
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->sp_entity ))
|
||||
if( !COM_StringEmpty( GameInfo->sp_entity ))
|
||||
FS_Printf( f, "sp_entity\t\t\"%s\"\n", GameInfo->sp_entity );
|
||||
if( COM_CheckStringEmpty( GameInfo->mp_entity ))
|
||||
if( !COM_StringEmpty( GameInfo->mp_entity ))
|
||||
FS_Printf( f, "mp_entity\t\t\"%s\"\n", GameInfo->mp_entity );
|
||||
if( COM_CheckStringEmpty( GameInfo->mp_filter ))
|
||||
if( !COM_StringEmpty( GameInfo->mp_filter ))
|
||||
FS_Printf( f, "mp_filter\t\t\"%s\"\n", GameInfo->mp_filter );
|
||||
|
||||
if( GameInfo->secure )
|
||||
@@ -718,7 +718,7 @@ static qboolean FS_WriteGameInfo( const char *filepath, const gameinfo_t *GameIn
|
||||
FS_Printf( f, "internal_vgui_support\t\t%i\n", GameInfo->internal_vgui_support );
|
||||
FS_Printf( f, "render_picbutton_text\t\t%i\n", GameInfo->render_picbutton_text );
|
||||
|
||||
if( COM_CheckStringEmpty( GameInfo->demomap ))
|
||||
if( !COM_StringEmpty( GameInfo->demomap ))
|
||||
FS_Printf( f, "demomap\t\t\"%s\"\n", GameInfo->demomap );
|
||||
|
||||
FS_Close( f ); // all done
|
||||
@@ -1018,7 +1018,7 @@ static void FS_ParseGenericGameInfo( gameinfo_t *GameInfo, const char *buf, cons
|
||||
|
||||
// demomap only valid for gameinfo.txt but HL1 after 25th anniversary update
|
||||
// comes with demo chapter. Set the demomap here.
|
||||
if( !COM_CheckStringEmpty( GameInfo->demomap ))
|
||||
if( COM_StringEmpty( GameInfo->demomap ))
|
||||
{
|
||||
if( !Q_stricmp( GameInfo->title, "Half-Life" )) // original check from GameUI
|
||||
Q_strncpy( GameInfo->demomap, "hldemo1", sizeof( GameInfo->demomap ));
|
||||
@@ -1043,7 +1043,7 @@ static void FS_ParseGenericGameInfo( gameinfo_t *GameInfo, const char *buf, cons
|
||||
Q_snprintf( token, sizeof( token ), "%s/%s", fs_rootdir, GameInfo->falldir );
|
||||
if( !FS_SysFolderExists( token ))
|
||||
{
|
||||
if( COM_CheckStringEmpty( fs_rodir ))
|
||||
if( !COM_StringEmpty( fs_rodir ))
|
||||
{
|
||||
Q_snprintf( token, sizeof( token ), "%s/%s", fs_rodir, GameInfo->falldir );
|
||||
if( !FS_SysFolderExists( token ))
|
||||
@@ -1264,7 +1264,7 @@ void FS_AddGameHierarchy( const char *dir, uint flags )
|
||||
qboolean isGameDir = flags & FS_GAMEDIR_PATH;
|
||||
char buf[MAX_VA_STRING];
|
||||
|
||||
if( !COM_CheckString( dir ))
|
||||
if( COM_StringEmptyOrNULL( dir ))
|
||||
return;
|
||||
|
||||
Con_Printf( "%s( %s )\n", __func__, dir );
|
||||
@@ -1298,7 +1298,7 @@ void FS_AddGameHierarchy( const char *dir, uint flags )
|
||||
}
|
||||
}
|
||||
|
||||
if( COM_CheckStringEmpty( fs_rodir ))
|
||||
if( !COM_StringEmpty( fs_rodir ))
|
||||
{
|
||||
// append new flags to rodir, except FS_GAMEDIR_PATH and FS_CUSTOM_PATH
|
||||
uint new_flags = FS_NOWRITE_PATH | (flags & (~FS_GAMEDIR_PATH|FS_CUSTOM_PATH));
|
||||
@@ -1337,7 +1337,7 @@ void FS_AddGameHierarchy( const char *dir, uint flags )
|
||||
FS_AddGameDirectory( buf, flags|FS_NOWRITE_PATH|FS_CUSTOM_PATH );
|
||||
}
|
||||
|
||||
if( FBitSet( flags, FS_MOUNT_L10N ) && COM_CheckStringEmpty( fs_language ) && Q_isalpha( fs_language ))
|
||||
if( FBitSet( flags, FS_MOUNT_L10N ) && !COM_StringEmpty( fs_language ) && Q_isalpha( fs_language ))
|
||||
{
|
||||
Q_snprintf( buf, sizeof( buf ), "%s_%s/", dir, fs_language );
|
||||
FS_AddGameDirectory( buf, flags|FS_NOWRITE_PATH|FS_CUSTOM_PATH );
|
||||
@@ -1370,11 +1370,11 @@ void FS_Rescan( uint32_t flags, const char *language )
|
||||
fs_language[0] = 0;
|
||||
|
||||
str = getenv( "XASH3D_EXTRAS_PAK1" );
|
||||
if( COM_CheckString( str ))
|
||||
if( !COM_StringEmptyOrNULL( str ))
|
||||
FS_MountArchive_Fullpath( str, FS_NOWRITE_PATH|FS_CUSTOM_PATH );
|
||||
|
||||
str = getenv( "XASH3D_EXTRAS_PAK2" );
|
||||
if( COM_CheckString( str ))
|
||||
if( !COM_StringEmptyOrNULL( str ))
|
||||
FS_MountArchive_Fullpath( str, FS_NOWRITE_PATH|FS_CUSTOM_PATH );
|
||||
|
||||
if( Q_stricmp( GI->basedir, GI->gamefolder ))
|
||||
@@ -1503,7 +1503,7 @@ static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dll
|
||||
int index, start = 0, len;
|
||||
|
||||
// check for bad exports
|
||||
if( !COM_CheckString( dllname ))
|
||||
if( COM_StringEmptyOrNULL( dllname ))
|
||||
return false;
|
||||
|
||||
FS_AllowDirectPaths( directpath );
|
||||
@@ -1552,7 +1552,7 @@ static qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dll
|
||||
// NOTE: gamedll might resolve it's own path using dladdr() and expects absolute path
|
||||
// NOTE: the only allowed case when searchpath is set by absolute path is the RoDir
|
||||
// rather than figuring out whether path is absolute, just check if it matches
|
||||
if( COM_CheckStringEmpty( fs_rodir ) && !Q_strnicmp( search->filename, fs_rodir, Q_strlen( fs_rodir )))
|
||||
if( !COM_StringEmpty( fs_rodir ) && !Q_strnicmp( search->filename, fs_rodir, Q_strlen( fs_rodir )))
|
||||
{
|
||||
Q_snprintf( dllInfo->fullPath, sizeof( dllInfo->fullPath ), "%s%s", search->filename, dllInfo->shortPath );
|
||||
}
|
||||
@@ -1689,7 +1689,7 @@ qboolean FS_InitStdio( qboolean unused_set_to_true, const char *rootdir, const c
|
||||
fs_language[0] = 0;
|
||||
|
||||
// validate user input
|
||||
if( COM_CheckStringEmpty( fs_rodir ) && !Q_stricmp( fs_rodir, fs_rootdir ))
|
||||
if( !COM_StringEmpty( fs_rodir ) && !Q_stricmp( fs_rodir, fs_rootdir ))
|
||||
{
|
||||
Sys_Error( "RoDir and default rootdir can't point to same directory!" );
|
||||
return false;
|
||||
@@ -1707,7 +1707,7 @@ qboolean FS_InitStdio( qboolean unused_set_to_true, const char *rootdir, const c
|
||||
if( !has_game_dir )
|
||||
{
|
||||
// look for game directories in RoDir now
|
||||
if( COM_CheckStringEmpty( fs_rodir ))
|
||||
if( !COM_StringEmpty( fs_rodir ))
|
||||
FS_ValidateDirectories( fs_rodir, &has_base_dir, &has_game_dir );
|
||||
|
||||
if( !has_game_dir )
|
||||
@@ -1722,7 +1722,7 @@ qboolean FS_InitStdio( qboolean unused_set_to_true, const char *rootdir, const c
|
||||
}
|
||||
|
||||
// now start building first level of directory hierarchy
|
||||
if( COM_CheckStringEmpty( fs_rodir ))
|
||||
if( !COM_StringEmpty( fs_rodir ))
|
||||
{
|
||||
Q_snprintf( buf, sizeof( buf ), "%s/", fs_rodir );
|
||||
FS_AddGameDirectory( buf, FS_STATIC_PATH|FS_NOWRITE_PATH );
|
||||
@@ -1730,7 +1730,7 @@ qboolean FS_InitStdio( qboolean unused_set_to_true, const char *rootdir, const c
|
||||
FS_AddGameDirectory( "./", FS_STATIC_PATH );
|
||||
|
||||
// but scan rodir for games first
|
||||
if( COM_CheckStringEmpty( fs_rodir ))
|
||||
if( !COM_StringEmpty( fs_rodir ))
|
||||
{
|
||||
stringlistinit( &dirs );
|
||||
listdirectory( &dirs, fs_rodir, true );
|
||||
@@ -3206,7 +3206,7 @@ qboolean FS_Rename( const char *oldname, const char *newname )
|
||||
if( !fs_writepath )
|
||||
return false;
|
||||
|
||||
if( !COM_CheckString( oldname ) || !COM_CheckString( newname ))
|
||||
if( COM_StringEmptyOrNULL( oldname ) || COM_StringEmptyOrNULL( newname ))
|
||||
return false;
|
||||
|
||||
// no work done
|
||||
@@ -3255,7 +3255,7 @@ qboolean GAME_EXPORT FS_Delete( const char *path )
|
||||
if( FS_CheckNastyPath( path ))
|
||||
return false;
|
||||
|
||||
if( !fs_writepath || !COM_CheckString( path ))
|
||||
if( !fs_writepath || COM_StringEmptyOrNULL( path ))
|
||||
return false;
|
||||
|
||||
Q_strncpy( path2, path, sizeof( path2 ));
|
||||
|
||||
@@ -100,7 +100,7 @@ static signed char W_TypeFromExt( const char *lumpname )
|
||||
int i;
|
||||
|
||||
// we not known about filetype, so match only by filename
|
||||
if( !Q_strcmp( ext, "*" ) || !COM_CheckStringEmpty( ext ))
|
||||
if( !Q_strcmp( ext, "*" ) || COM_StringEmpty( ext ))
|
||||
return TYP_ANY;
|
||||
|
||||
for( i = 0; i < sizeof( wad_types ) / sizeof( wad_types[0] ); i++ )
|
||||
@@ -439,7 +439,7 @@ static int FS_FindFile_WAD( searchpath_t *search, const char *path, char *fixedn
|
||||
|
||||
COM_ExtractFilePath( path, wadname );
|
||||
|
||||
if( COM_CheckStringEmpty( wadname ))
|
||||
if( !COM_StringEmpty( wadname ))
|
||||
{
|
||||
string wadbasename;
|
||||
|
||||
@@ -496,7 +496,7 @@ static void FS_Search_WAD( searchpath_t *search, stringlist_t *list, const char
|
||||
COM_FileBase( pattern, wadpattern, sizeof( wadpattern ));
|
||||
wadfolder[0] = '\0';
|
||||
|
||||
if( COM_CheckStringEmpty( wadname ))
|
||||
if( !COM_StringEmpty( wadname ))
|
||||
{
|
||||
string wadbasename;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user