From fb5b4fed6eb7b00803f15bd62c18665130a9585d Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 16 Jun 2026 15:13:30 +0500 Subject: [PATCH] filesystem: VFileSystem009: fix DeleteFile --- filesystem/VFileSystem009.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/filesystem/VFileSystem009.cpp b/filesystem/VFileSystem009.cpp index 4fbde216..b4515898 100644 --- a/filesystem/VFileSystem009.cpp +++ b/filesystem/VFileSystem009.cpp @@ -28,7 +28,7 @@ GNU General Public License for more details. // GoldSrc Directories and ID // GAME gamedir // GAMECONFIG gamedir (rodir integration?) -// GAMEDOWNLOAD gamedir_downloads (gamedir/downloads for us) +// GAMEDOWNLOAD gamedir_downloads // GAME_FALLBACK liblist.gam's fallback_dir // ROOT and BASE rootdir // PLATFORM platform @@ -41,14 +41,22 @@ GNU General Public License for more details. char * const var = static_cast( alloca( var ## _size )); \ CopyAndFixSlashes( var, ( str ), var ## _size ) -static inline bool IsIdGamedir( const char *id ) +static bool IsIdGamedir( const char *id ) { return !Q_strcmp( id, "GAME" ) || !Q_strcmp( id, "GAMECONFIG" ) || !Q_strcmp( id, "GAMEDOWNLOAD" ); } -static inline const char *IdToDir( char *dir, size_t size, const char *id ) +static searchpath_t *IdToWritableSearchpath( const char *id ) +{ + if( !Q_strcmp( id, "GAME" ) || !Q_strcmp( id, "GAMECONFIG" )) + return fs_writepath; + + return NULL; +} + +static const char *IdToDir( char *dir, size_t size, const char *id ) { if( !Q_strcmp( id, "GAME" )) return GI->gamefolder; @@ -72,7 +80,7 @@ static inline const char *IdToDir( char *dir, size_t size, const char *id ) return fs_rootdir; // give at least root directory } -static inline void CopyAndFixSlashes( char *p, const char *in, size_t size ) +static void CopyAndFixSlashes( char *p, const char *in, size_t size ) { Q_strncpy( p, in, size ); COM_FixSlashes( p ); @@ -147,10 +155,9 @@ public: void RemoveFile( const char *path, const char *id ) override { - char dir[MAX_VA_STRING], fullpath[MAX_VA_STRING]; - - Q_snprintf( fullpath, sizeof( fullpath ), "%s/%s", IdToDir( dir, sizeof( dir ), id ), path ); - FS_Delete( fullpath ); // FS_Delete is aware of slashes + // FIXME: handle writable downloads path + if( IdToWritableSearchpath( id )) + FS_Delete( path ); // FS_Delete is aware of slashes } void CreateDirHierarchy( const char *path, const char *id ) override