diff --git a/filesystem/dll.c b/filesystem/dll.c index c8e8a860..3dd0244f 100644 --- a/filesystem/dll.c +++ b/filesystem/dll.c @@ -222,6 +222,7 @@ const fs_api_t g_api = FS_GetRootDirectory, FS_MakeGameInfo, + FS_FindFile_f, }; int EXPORT GetFSAPI( int version, fs_api_t *api, fs_globals_t **globals, fs_interface_t *engfuncs ); diff --git a/filesystem/filesystem.h b/filesystem/filesystem.h index bc858782..0bc15d13 100644 --- a/filesystem/filesystem.h +++ b/filesystem/filesystem.h @@ -241,6 +241,7 @@ typedef struct fs_api_t qboolean (*GetRootDirectory)( char *path, size_t size ); void (*MakeGameInfo)( void ); + void (*FindFile_f)( const char *filename ); } fs_api_t; typedef struct fs_interface_t diff --git a/filesystem/filesystem_internal.h b/filesystem/filesystem_internal.h index e3591ec1..da5a84ca 100644 --- a/filesystem/filesystem_internal.h +++ b/filesystem/filesystem_internal.h @@ -170,6 +170,7 @@ qboolean FS_InitStdio( qboolean caseinsensitive, const char *rootdir, const char void FS_AllowDirectPaths( qboolean enable ); void FS_ShutdownStdio( void ); void FS_Path_f( void ); +void FS_FindFile_f( const char *filename ); searchpath_t *FS_FindFile( const char *name, int *index, char *fixedname, size_t len, uint32_t flags ); qboolean FS_FindLibrary( const char *dllname, qboolean directpath, fs_dllinfo_t *dllInfo ); qboolean FS_FullPathToRelativePath( char *dst, const char *src, size_t size ); diff --git a/filesystem/searchpath.c b/filesystem/searchpath.c index 28e2e5b2..2246c6e4 100644 --- a/filesystem/searchpath.c +++ b/filesystem/searchpath.c @@ -773,6 +773,35 @@ void FS_Path_f( void ) } } +/* +==================== +FS_FindFile_f + +Print all search paths where the file was found, +ordered by priority (first one is used for FS operations) +==================== +*/ +void FS_FindFile_f( const char *filename ) +{ + int count = 0; + Con_Printf( "File " S_YELLOW "%s" S_DEFAULT " occurences:\n", filename ); + + for( searchpath_t *s = fs_searchpaths; s; s = s->next ) + { + string fixedname; + if( s->pfnFindFile( s, filename, fixedname, sizeof( fixedname )) >= 0 ) + { + string info; + count++; + s->pfnPrintInfo( s, info, sizeof( info )); + Con_Printf( " " S_CYAN "%s%s\n", info, count == 1 ? " " S_GREEN "(active)" : "" ); + } + } + + if( count == 0 ) + Con_Printf( " " S_RED "(not found)\n" ); +} + /* ==================== FS_FindFile