filesystem: add implementation of "fs_find" console command

This commit is contained in:
SNMetamorph
2026-05-21 01:03:06 +04:00
committed by a1batross
parent 853a67b0c5
commit ecd74a0a7f
4 changed files with 32 additions and 0 deletions

View File

@@ -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 );

View File

@@ -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

View File

@@ -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 );

View File

@@ -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