filesystem: VFileSystem009: fix DeleteFile

This commit is contained in:
Alibek Omarov
2026-06-16 15:13:30 +05:00
parent 1e31fbcd51
commit fb5b4fed6e

View File

@@ -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<char *>( 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