-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetaFile.cpp
More file actions
41 lines (33 loc) · 987 Bytes
/
MetaFile.cpp
File metadata and controls
41 lines (33 loc) · 987 Bytes
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
#include "MetaFile.h"
#include <cassert>
#include <stdexcept>
namespace kukdh1 {
PAZTable::PAZTable(uint8_t *buffer) {
memcpy(&uiPazFileID, buffer + 0, 4);
memcpy(&uiCRC, buffer + 4, 4);
memcpy(&uiSize, buffer + 8, 4);
}
Meta::Meta(wchar_t *wpszPazFolder) {
assert(wpszPazFolder != nullptr);
std::fstream file;
std::wstring path(wpszPazFolder);
path.append(L"\\pad00000.meta");
file.open(path, std::ios::in | std::ios::binary);
if (file.is_open()) {
uint8_t buffer[64];
// Read Header
file.read((char *)buffer, 8);
memcpy(&uiVersion, buffer + 0, 4);
memcpy(&uiPAZFileCount, buffer + 4, 4);
// Read PAZ File information
for (uint32_t idx = 0; idx < uiPAZFileCount; idx++) {
file.read((char *)buffer, 12);
vPAZs.push_back(PAZTable(buffer));
}
file.close();
}
else {
throw std::runtime_error("Cannot open meta file: pad00000.meta not found in selected folder");
}
}
}