From fbe1e2c18a0672d6c529a139e95e9d145e3c13c3 Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 12 May 2009 11:55:14 +0000 Subject: [PATCH] a new "which" command showing which pk3 a file is from git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8955 d7cf8633-e32d-0410-b094-e92efae38249 --- darkplaces.txt | 2 +- fs.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/darkplaces.txt b/darkplaces.txt index 7873f233..1c661bb5 100644 --- a/darkplaces.txt +++ b/darkplaces.txt @@ -1245,7 +1245,7 @@ viewmodel change model of viewthing enti viewnext change to next animation frame of viewthing entity in current level viewprev change to previous animation frame of viewthing entity in current level wait make script execution wait for next rendered frame - +which accepts a file name as argument and reports where the file is taken from How to install Quake on Windows: diff --git a/fs.c b/fs.c index 1dc6a8b5..0dfc6eaa 100644 --- a/fs.c +++ b/fs.c @@ -285,6 +285,7 @@ FUNCTION PROTOTYPES void FS_Dir_f(void); void FS_Ls_f(void); +void FS_Which_f(void); static searchpath_t *FS_FindFile (const char *name, int* index, qboolean quiet); static packfile_t* FS_AddFileToPack (const char* name, pack_t* pack, @@ -1567,6 +1568,7 @@ void FS_Init_Commands(void) Cmd_AddCommand ("path", FS_Path_f, "print searchpath (game directories and archives)"); Cmd_AddCommand ("dir", FS_Dir_f, "list files in searchpath matching an * filename pattern, one per line"); Cmd_AddCommand ("ls", FS_Ls_f, "list files in searchpath matching an * filename pattern, multiple per line"); + Cmd_AddCommand ("which", FS_Which_f, "accepts a file name as argument and reports where the file is taken from"); } /* @@ -3101,6 +3103,29 @@ void FS_Ls_f(void) FS_ListDirectoryCmd("ls", false); } +void FS_Which_f(void) +{ + const char *filename; + int index; + searchpath_t *sp; + if (Cmd_Argc() != 2) + { + Con_Printf("usage:\n%s \n", Cmd_Argv(0)); + return; + } + filename = Cmd_Argv(1); + sp = FS_FindFile(filename, &index, true); + if (!sp) { + Con_Printf("%s isn't anywhere\n", filename); + return; + } + if (sp->pack) + Con_Printf("%s is in package %s\n", filename, sp->pack->shortname); + else + Con_Printf("%s is file %s%s\n", filename, sp->filename, filename); +} + + const char *FS_WhichPack(const char *filename) { int index; -- 2.39.2