-
Notifications
You must be signed in to change notification settings - Fork 0
/
wad_dump.cpp
49 lines (40 loc) · 1.29 KB
/
wad_dump.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include "Wad.h"
using namespace std;
void exploreDirectory(Wad *data, const string path, int level)
{
for (int index = 0; index < level; index++)
cout << " ";
vector<string> entries;
cout << "[Objects at this level:" << data->getDirectory(path, &entries) << "]" << endl;
for (string entry : entries)
{
string entryPath = path + entry;
for (int index = 0; index < level; index++)
cout << " ";
if (data->isDirectory(entryPath))
{
cout << level << ". DIR: " << entry << endl;
exploreDirectory(data, entryPath + "/", level + 1);
}
else if (data->isContent(entryPath))
cout << level << ". CONTENT: " << entry << "; Size: " << data->getSize(entryPath) << endl;
else
cout << "***WARNING: entry " << entry << " has invalid type!***" << endl;
}
}
void exploreDirectory(Wad *data, const string path)
{
cout << "EXPLORING: " << path << endl;
exploreDirectory(data, path, 1);
}
int main(int argc, char** argv)
{
if (argc < 2)
{
cout << "No file specified. Exiting." << endl;
exit(EXIT_SUCCESS);
}
Wad *myWad = Wad::loadWad(argv[1]);
exploreDirectory(myWad, "/");
}