-
Notifications
You must be signed in to change notification settings - Fork 1
/
GameFile.h
51 lines (38 loc) · 1.05 KB
/
GameFile.h
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
//
// Created by mydayyy on 8/12/18.
//
#ifndef THISWAROFMINEUNPACKER_GAMEFILE_H
#define THISWAROFMINEUNPACKER_GAMEFILE_H
#include <iostream>
#include <fstream>
#include <stdexcept>
#include <map>
#include <algorithm>
#include <experimental/filesystem>
#include "Z.h"
namespace fs = std::experimental::filesystem;
struct FileIndex {
FileIndex() : hash(0), size(0), inflatedSize(0), offset(0), isCompressed(0) {}
uint32_t hash;
uint32_t size;
uint32_t inflatedSize;
uint32_t offset;
uint8_t isCompressed;
};
class GameFile {
public:
GameFile(std::string fileName, std::string dest, std::map<uint32_t, std::string> &fileNames);
bool readIndices();
bool extractFiles();
private:
void createFolders();
uint32_t read32LE(std::ifstream *file);
uint8_t read8(std::ifstream *file);
std::string fileName;
std::string indexFile;
std::string dataFile;
std::string dest;
std::map<uint32_t, std::string> fileNames;
std::map<uint32_t, FileIndex> indices;
};
#endif //THISWAROFMINEUNPACKER_GAMEFILE_H