11 if (!std::filesystem::exists(path)) {
16 auto* hog =
new HOG{path};
17 auto packFile = std::unique_ptr<PackFile>(hog);
19 FileStream reader{hog->fullFilePath};
23 if (
const auto signature = reader.read_string(3); signature !=
HOG_SIGNATURE) {
33 const auto entryPath = hog->cleanEntryPath(reader.read_string(13));
41 entry.
length = reader.read<uint32_t>();
42 entry.
offset = reader.tell_in();
48 hog->entries.emplace(entryPath, entry);
51 callback(entryPath, entry);
58std::optional<std::vector<std::byte>>
HOG::readEntry(
const std::string& path_)
const {
73 stream.seek_in_u(entry->offset);
74 return stream.read_bytes(entry->length);
This class represents the metadata that a file has inside a PackFile.
uint64_t offset
Offset, format-specific meaning - 0 if unused, or if the offset genuinely is 0.
uint64_t length
Length in bytes (in formats with compression, this is the uncompressed length)
Attribute getSupportedEntryAttributes() const override
Returns a list of supported entry attributes Mostly for GUI programs that show entries and their meta...
static std::unique_ptr< PackFile > open(const std::string &path, const EntryCallback &callback=nullptr)
Open a HOG file.
std::optional< std::vector< std::byte > > readEntry(const std::string &path_) const override
Try to read the entry's data to a bytebuffer.
EntryCallbackBase< void > EntryCallback
std::optional< Entry > findEntry(const std::string &path_, bool includeUnbaked=true) const
Try to find an entry given the file path.
std::string cleanEntryPath(const std::string &path) const
static Entry createNewEntry()
static std::optional< std::vector< std::byte > > readUnbakedEntry(const Entry &entry)
constexpr std::string_view HOG_SIGNATURE