diff --git a/filesystem/VFileSystem009.cpp b/filesystem/VFileSystem009.cpp index f0ed6be1..a5517d0a 100644 --- a/filesystem/VFileSystem009.cpp +++ b/filesystem/VFileSystem009.cpp @@ -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 diff --git a/filesystem/filesystem.c b/filesystem/filesystem.c index 6c292114..3fe14d7c 100644 --- a/filesystem/filesystem.c +++ b/filesystem/filesystem.c @@ -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; +} + /* =========== diff --git a/filesystem/filesystem_internal.h b/filesystem/filesystem_internal.h index 17c77dda..5b741e54 100644 --- a/filesystem/filesystem_internal.h +++ b/filesystem/filesystem_internal.h @@ -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