Skip to content

Commit

Permalink
Add list used files command
Browse files Browse the repository at this point in the history
  • Loading branch information
perturbed authored and illwieckz committed Mar 10, 2019
1 parent 714566b commit 120ecc7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/engine/qcommon/files.cpp
Expand Up @@ -87,6 +87,8 @@ bool FS_FileExists(const char* path)
return FS::PakPath::FileExists(path) || FS::HomePath::FileExists(path);
}

std::set<std::string> usedFiles;

int FS_FOpenFileRead(const char* path, fileHandle_t* handle, bool)
{
if (!handle)
Expand All @@ -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;
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 120ecc7

Please sign in to comment.