forked from hrydgard/ppsspp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPBPReader.h
68 lines (53 loc) · 1.63 KB
/
PBPReader.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2013- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#include "Common/Common.h"
#include "Common/Swap.h"
enum PBPSubFile {
PBP_PARAM_SFO,
PBP_ICON0_PNG,
PBP_ICON1_PMF,
PBP_PIC0_PNG,
PBP_PIC1_PNG,
PBP_SND0_AT3,
PBP_EXECUTABLE_PSP,
PBP_UNKNOWN_PSAR,
};
struct PBPHeader {
char magic[4];
u32_le version;
u32_le offsets[8];
};
class FileLoader;
class PBPReader {
public:
PBPReader(FileLoader *fileLoader);
~PBPReader();
bool IsValid() const { return file_ != nullptr; }
bool IsELF() const { return file_ == nullptr && isELF_; }
bool GetSubFile(PBPSubFile file, std::vector<u8> *out);
void GetSubFileAsString(PBPSubFile file, std::string *out);
size_t GetSubFileSize(PBPSubFile file) {
int num = (int)file;
if (num < 7) {
return header_.offsets[file + 1] - header_.offsets[file];
} else {
return fileSize_ - header_.offsets[file];
}
}
private:
FileLoader *file_;
size_t fileSize_;
const PBPHeader header_;
bool isELF_;
};