Skip to content

Commit 120ecc7

Browse files
perturbedillwieckz
authored andcommitted
Add list used files command
1 parent 714566b commit 120ecc7

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/engine/qcommon/files.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ bool FS_FileExists(const char* path)
8787
return FS::PakPath::FileExists(path) || FS::HomePath::FileExists(path);
8888
}
8989

90+
std::set<std::string> usedFiles;
91+
9092
int FS_FOpenFileRead(const char* path, fileHandle_t* handle, bool)
9193
{
9294
if (!handle)
@@ -96,6 +98,7 @@ int FS_FOpenFileRead(const char* path, fileHandle_t* handle, bool)
9698
int length = -1;
9799
std::error_code err;
98100
if (FS::PakPath::FileExists(path)) {
101+
usedFiles.insert(path);
99102
handleTable[*handle].fileData = FS::PakPath::ReadFile(path, err);
100103
if (!err) {
101104
handleTable[*handle].filePos = 0;
@@ -749,6 +752,25 @@ class WhichCmd: public Cmd::StaticCmd {
749752
};
750753
static WhichCmd WhichCmdRegistration;
751754

755+
class ListUsedFilesCmd : public Cmd::StaticCmd {
756+
public:
757+
ListUsedFilesCmd()
758+
: Cmd::StaticCmd("listUsedFiles", Cmd::SYSTEM, "list used files from pak path") {}
759+
760+
void Run(const Cmd::Args& args) const override
761+
{
762+
if (args.Argc() != 1) {
763+
PrintUsage(args, "", "");
764+
return;
765+
}
766+
767+
for (auto filename : usedFiles) {
768+
Print("%s", filename);
769+
}
770+
}
771+
};
772+
static ListUsedFilesCmd ListFilesCmdRegistration;
773+
752774
class ListPathsCmd: public Cmd::StaticCmd {
753775
public:
754776
ListPathsCmd()

0 commit comments

Comments
 (0)