filesystem: make fs_searchpaths completely private to the filesystem core

This commit is contained in:
Alibek Omarov 2023-06-08 22:30:45 +03:00
parent 0d6137ee40
commit 37e890f326
3 changed files with 30 additions and 17 deletions

View File

@ -406,8 +406,6 @@ public:
bool FullPathToRelativePath( const char *path, char *out ) override
{
searchpath_t *sp;
if( !COM_CheckString( path ))
{
*out = 0;
@ -416,19 +414,7 @@ public:
FixupPath( p, path );
for( sp = fs_searchpaths; sp; sp = sp->next )
{
size_t splen = Q_strlen( sp->filename );
if( !Q_strnicmp( sp->filename, p, splen ))
{
Q_strncpy( out, p + splen + 1, 512 );
return true;
}
}
Q_strncpy( out, p, 512 );
return false;
return FS_FullPathToRelativePath( out, p, 512 );
}
bool GetCurrentDirectory( char *p, int size ) override

View File

@ -48,11 +48,11 @@ GNU General Public License for more details.
fs_globals_t FI;
qboolean fs_ext_path = false; // attempt to read\write from ./ or ../ pathes
poolhandle_t fs_mempool;
searchpath_t *fs_searchpaths = NULL; // chain
char fs_rodir[MAX_SYSPATH];
char fs_rootdir[MAX_SYSPATH];
searchpath_t *fs_writepath;
static searchpath_t *fs_searchpaths = NULL; // chain
static char fs_basedir[MAX_SYSPATH]; // base game directory
static char fs_gamedir[MAX_SYSPATH]; // game current directory
@ -1843,6 +1843,33 @@ searchpath_t *FS_FindFile( const char *name, int *index, char *fixedname, size_t
return NULL;
}
/*
===========================
FS_FullPathToRelativePath
Converts full path to the relative path considering current searchpaths
(do not use this function, implemented only for VFileSystem009)
===========================
*/
qboolean FS_FullPathToRelativePath( char *dst, const char *src, size_t size )
{
searchpath_t *sp;
for( sp = fs_searchpaths; sp; sp = sp->next )
{
size_t splen = Q_strlen( sp->filename );
if( !Q_strnicmp( sp->filename, src, splen ))
{
Q_strncpy( dst, src + splen + 1, size );
return true;
}
}
Q_strncpy( dst, src, size );
return false;
}
/*
===========

View File

@ -104,7 +104,6 @@ typedef struct fs_archive_s
} fs_archive_t;
extern fs_globals_t FI;
extern searchpath_t *fs_searchpaths;
extern searchpath_t *fs_writepath;
extern poolhandle_t fs_mempool;
extern fs_interface_t g_engfuncs;
@ -201,6 +200,7 @@ int FS_SysFileTime( const char *filename );
file_t *FS_OpenHandle( const char *syspath, int handle, fs_offset_t offset, fs_offset_t len );
file_t *FS_SysOpen( const char *filepath, const char *mode );
searchpath_t *FS_FindFile( const char *name, int *index, char *fixedname, size_t len, qboolean gamedironly );
qboolean FS_FullPathToRelativePath( char *dst, const char *src, size_t size );
//
// pak.c