mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
filesystem: add implementation of "fs_find" console command
This commit is contained in:
@@ -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 );
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user