From 120ecc7e5c655df5ba1a330a485aec4e6725aeed Mon Sep 17 00:00:00 2001 From: perturbed Date: Tue, 22 Mar 2016 23:08:54 -0500 Subject: [PATCH] Add list used files command --- src/engine/qcommon/files.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/engine/qcommon/files.cpp b/src/engine/qcommon/files.cpp index e699b11f14..76a73d4d8d 100644 --- a/src/engine/qcommon/files.cpp +++ b/src/engine/qcommon/files.cpp @@ -87,6 +87,8 @@ bool FS_FileExists(const char* path) return FS::PakPath::FileExists(path) || FS::HomePath::FileExists(path); } +std::set usedFiles; + int FS_FOpenFileRead(const char* path, fileHandle_t* handle, bool) { if (!handle) @@ -96,6 +98,7 @@ int FS_FOpenFileRead(const char* path, fileHandle_t* handle, bool) int length = -1; std::error_code err; if (FS::PakPath::FileExists(path)) { + usedFiles.insert(path); handleTable[*handle].fileData = FS::PakPath::ReadFile(path, err); if (!err) { handleTable[*handle].filePos = 0; @@ -749,6 +752,25 @@ class WhichCmd: public Cmd::StaticCmd { }; static WhichCmd WhichCmdRegistration; +class ListUsedFilesCmd : public Cmd::StaticCmd { +public: + ListUsedFilesCmd() + : Cmd::StaticCmd("listUsedFiles", Cmd::SYSTEM, "list used files from pak path") {} + + void Run(const Cmd::Args& args) const override + { + if (args.Argc() != 1) { + PrintUsage(args, "", ""); + return; + } + + for (auto filename : usedFiles) { + Print("%s", filename); + } + } +}; +static ListUsedFilesCmd ListFilesCmdRegistration; + class ListPathsCmd: public Cmd::StaticCmd { public: ListPathsCmd()