-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (53 loc) · 1.76 KB
/
main.cpp
File metadata and controls
65 lines (53 loc) · 1.76 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//#include <iostream>
//
//int main() {
// std::cout << "Hello, World!" << std::endl;
// return 0;
//}
#include <iostream>
#include <fstream>
#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]);
string dataPath = "/F/F1/CEIL4_2";
char* dataBuffer = new char[myWad->getSize(dataPath)];
int count = myWad->getContents(dataPath, dataBuffer, myWad->getSize(dataPath));
cout << "File contents for: " << dataPath << " is size: " << count << endl;
cout << "Actual file contents are: " << dataBuffer << endl;
delete[] dataBuffer;
//exploreDirectory(myWad, "/F/F1/");
}