]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
a new "which" command showing which pk3 a file is from
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 12 May 2009 11:55:14 +0000 (11:55 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 12 May 2009 11:55:14 +0000 (11:55 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8955 d7cf8633-e32d-0410-b094-e92efae38249

darkplaces.txt
fs.c

index 7873f233d922fdd2e185159372813394957cc10d..1c661bb52959f449eebcfd6a23fe802728bbdce1 100644 (file)
@@ -1245,7 +1245,7 @@ viewmodel                                         change model of viewthing enti
 viewnext                                          change to next animation frame of viewthing entity in current level\r
 viewprev                                          change to previous animation frame of viewthing entity in current level\r
 wait                                              make script execution wait for next rendered frame\r
-\r
+which                                             accepts a file name as argument and reports where the file is taken from\r
 \r
 \r
 How to install Quake on Windows:\r
diff --git a/fs.c b/fs.c
index 1dc6a8b5a62ddf05f27188db1183a8beb2e78b60..0dfc6eaa7b62e087251c4f4a3e947ac4b0e52edb 100644 (file)
--- 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 <file>\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;