pfs: Provide accessors for file sizes and offsets

This commit is contained in:
Zach Hilman 2019-09-22 21:44:36 -04:00
parent 2f5545f8de
commit 3895f7e456
2 changed files with 17 additions and 0 deletions

View file

@ -65,6 +65,9 @@ PartitionFilesystem::PartitionFilesystem(std::shared_ptr<VfsFile> file) {
std::string name(
reinterpret_cast<const char*>(&file_data[strtab_offset + entry.strtab_offset]));
offsets[name] = content_offset + entry.offset;
sizes[name] = entry.size;
pfs_files.emplace_back(std::make_shared<OffsetVfsFile>(
file, entry.size, content_offset + entry.offset, std::move(name)));
}
@ -78,6 +81,14 @@ Loader::ResultStatus PartitionFilesystem::GetStatus() const {
return status;
}
std::map<std::string, u64> PartitionFilesystem::GetFileOffsets() const {
return offsets;
}
std::map<std::string, u64> PartitionFilesystem::GetFileSizes() const {
return sizes;
}
std::vector<std::shared_ptr<VfsFile>> PartitionFilesystem::GetFiles() const {
return pfs_files;
}

View file

@ -29,6 +29,9 @@ public:
Loader::ResultStatus GetStatus() const;
std::map<std::string, u64> GetFileOffsets() const;
std::map<std::string, u64> GetFileSizes() const;
std::vector<std::shared_ptr<VfsFile>> GetFiles() const override;
std::vector<std::shared_ptr<VfsDirectory>> GetSubdirectories() const override;
std::string GetName() const override;
@ -80,6 +83,9 @@ private:
bool is_hfs = false;
std::size_t content_offset = 0;
std::map<std::string, u64> offsets;
std::map<std::string, u64> sizes;
std::vector<VirtualFile> pfs_files;
};