wavelength 1.0.0
Loading...
Searching...
No Matches
Tools::Ark::ArkReader Class Reference

Reader of a version 2 archive, the gen/main.ark of Amplitude and of its P.O.D. More...

#include <arkreader.h>

Public Member Functions

const std::vector< ArkEntry > & entries () const
 List the files in record order.
std::optional< ArkEntry > locate (std::string_view path) const
 Find a file the way Archive::GetFileInfo does, through the name hash table.
std::expected< std::vector< std::uint8_t >, Error > read (const ArkEntry &entry)
 Read the bytes of a file.
std::expected< void, Error > extract (const std::filesystem::path &root)
 Copy every file into a directory, at its path below the directory.

Static Public Member Functions

static std::expected< ArkReader, Error > open (const std::filesystem::path &path, std::uint64_t base=0)
 Open an archive and read its directory.

Static Public Attributes

static constexpr std::uint32_t kVersion = 2
 The archive version the game reads.

Detailed Description

Reader of a version 2 archive, the gen/main.ark of Amplitude and of its P.O.D.

demo.

The archive opens with the version, the file records, the string block of the names, and the name hash table, and the file data follows. A record identifies its name and its directory by their hash table slots.

Member Function Documentation

◆ open()

std::expected< ArkReader, Error > Tools::Ark::ArkReader::open ( const std::filesystem::path & path,
std::uint64_t base = 0 )
static

Open an archive and read its directory.

Parameters
pathThe archive, or a disc image that stores it.
baseOffset of the archive in the file, for an archive inside a disc image.
Returns
The reader, or an error when the file cannot be read or its directory is not valid.

◆ entries()

const std::vector< ArkEntry > & Tools::Ark::ArkReader::entries ( ) const
nodiscard

List the files in record order.

Returns
The files.

◆ locate()

std::optional< ArkEntry > Tools::Ark::ArkReader::locate ( std::string_view path) const
nodiscard

Find a file the way Archive::GetFileInfo does, through the name hash table.

Parameters
pathPath of the file.
Returns
The file, or nothing when the hash table or the records lack it.

◆ read()

std::expected< std::vector< std::uint8_t >, Error > Tools::Ark::ArkReader::read ( const ArkEntry & entry)

Read the bytes of a file.

Parameters
entryThe file.
Returns
The bytes, or an error when the archive ends early.

◆ extract()

std::expected< void, Error > Tools::Ark::ArkReader::extract ( const std::filesystem::path & root)

Copy every file into a directory, at its path below the directory.

Parameters
rootDestination directory. It is created when missing.
Returns
Nothing, or an error when a file cannot be read or written.

Member Data Documentation

◆ kVersion

std::uint32_t Tools::Ark::ArkReader::kVersion = 2
staticconstexpr

The archive version the game reads.


The documentation for this class was generated from the following file: