From 95cc6c44457ed1f3c3ceb12743647e204db0962d Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 5 May 2026 14:12:01 +0500 Subject: [PATCH] filesystem: small refactoring, remove double nullptr checks --- filesystem/filesystem.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/filesystem/filesystem.c b/filesystem/filesystem.c index 42d390c9..5e008a09 100644 --- a/filesystem/filesystem.c +++ b/filesystem/filesystem.c @@ -3204,16 +3204,6 @@ qboolean FS_Rename( const char *oldname, const char *newname ) if( FS_CheckNastyPath( oldname ) || FS_CheckNastyPath( newname )) return false; - if( !fs_writepath ) - return false; - - if( COM_StringEmptyOrNULL( oldname ) || COM_StringEmptyOrNULL( newname )) - return false; - - // no work done - if( !Q_stricmp( oldname, newname )) - return true; - // fix up slashes Q_strncpy( oldname2, oldname, sizeof( oldname2 )); Q_strncpy( newname2, newname, sizeof( newname2 )); @@ -3221,6 +3211,14 @@ qboolean FS_Rename( const char *oldname, const char *newname ) COM_FixSlashes( oldname2 ); COM_FixSlashes( newname2 ); + // no work done + if( !Q_stricmp( oldname2, newname2 )) + return true; + + // no writing directory is set, no changes should be made + if( !fs_writepath ) + return false; + // file does not exist if( !FS_FixFileCase( fs_writepath->dir, oldname2, oldpath, sizeof( oldpath ), false )) return false; @@ -3256,7 +3254,7 @@ qboolean GAME_EXPORT FS_Delete( const char *path ) if( FS_CheckNastyPath( path )) return false; - if( !fs_writepath || COM_StringEmptyOrNULL( path )) + if( !fs_writepath ) return false; Q_strncpy( path2, path, sizeof( path2 ));