mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-22 10:49:05 +02:00
PBPReader: Read part of a subfile
GetSubFile() reads a whole subfile, and refuses those over 256MB. ReadSubFile() reads a range of one, for the PSAR of a PS1 EBOOT, which holds its disc image.
This commit is contained in:
1 parent
3d69708fca
commit
d037ca1b7b
2 files changed
+13
No files matched your search
@@ -79,6 +79,17 @@ bool PBPReader::GetSubFile(PBPSubFile file, std::vector<u8> *out) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PBPReader::ReadSubFile(PBPSubFile file, u32 offset, size_t size, void *out) const {
|
||||
if (!file_) {
|
||||
return false;
|
||||
}
|
||||
const size_t subFileSize = GetSubFileSize(file);
|
||||
if (offset > subFileSize || size > subFileSize - offset) {
|
||||
return false;
|
||||
}
|
||||
return file_->ReadAt(header_.offsets[(int)file] + offset, size, out) == size;
|
||||
}
|
||||
|
||||
bool PBPReader::GetSubFileAsString(PBPSubFile file, std::string *out) const {
|
||||
if (!file_) {
|
||||
out->clear();
|
||||
|
||||
@@ -53,6 +53,8 @@ public:
|
||||
|
||||
bool GetSubFile(PBPSubFile file, std::vector<u8> *out) const;
|
||||
bool GetSubFileAsString(PBPSubFile file, std::string *out) const;
|
||||
// Part of a subfile, for the large ones. False if it doesn't lie within it.
|
||||
bool ReadSubFile(PBPSubFile file, u32 offset, size_t size, void *out) const;
|
||||
|
||||
size_t GetSubFileSize(PBPSubFile file) const {
|
||||
const int num = (int)file;
|
||||
|
||||
Reference in new issue
Block a user