bsa::tes3::file class final

Represents a file within the TES3 virtual filesystem.

Base classes

class bsa::components::byte_container
A byte storage container without compression support.

Capacity

auto empty() const -> bool noexcept
Checks if the underlying byte container is empty.
auto size() const -> std::size_t noexcept
Returns the size of the underlying byte container.

Doxygen only

void doxygen_read() protected
Reads the contents of the source.
void doxygen_write() const protected

Element access

auto as_bytes() const -> std::span<const std::byte> noexcept
Retrieves an immutable view into the underlying bytes.
auto data() const -> const std::byte* noexcept
Retrieves an immutable pointer to the underlying bytes.

Member types

using key = components::key<hashing::hash, hashing::hash_file_in_place>
The key used to indentify a file.

Modifiers

void clear() noexcept
Clears the contents of the file.
void set_data(std::span<const std::byte> a_data) noexcept
Assigns the underlying container to be a non-owning view into the given data.
void set_data(std::vector<std::byte> a_data) noexcept
Assigns the underlying container to be an owning view into the given data.

Reading

void read(std::filesystem::path a_path)
Reads the contents of the source.
void read(std::span<const std::byte> a_src, copy_type a_copy = copy_type::deep)
Reads the contents of the source.

Writing

void write(std::filesystem::path a_path) const
void write(binary_io::any_ostream& a_dst) const

Function documentation

bool bsa::tes3::file::empty() const noexcept

Checks if the underlying byte container is empty.

std::size_t bsa::tes3::file::size() const noexcept

Returns the size of the underlying byte container.

void bsa::tes3::file::doxygen_read() protected

Reads the contents of the source.

Exceptions
binary_io::buffer_exhausted Thrown when reads index out of bounds.

std::span<const std::byte> bsa::tes3::file::as_bytes() const noexcept

Retrieves an immutable view into the underlying bytes.

const std::byte* bsa::tes3::file::data() const noexcept

Retrieves an immutable pointer to the underlying bytes.

void bsa::tes3::file::set_data(std::span<const std::byte> a_data) noexcept

Assigns the underlying container to be a non-owning view into the given data.

Parameters
a_data The data to store a view to.

void bsa::tes3::file::set_data(std::vector<std::byte> a_data) noexcept

Assigns the underlying container to be an owning view into the given data.

Parameters
a_data The data to take ownership of.

void bsa::tes3::file::read(std::filesystem::path a_path)

Reads the contents of the source.

Parameters
a_path The path to the given archive on the native filesystem.
Exceptions
binary_io::buffer_exhausted Thrown when reads index out of bounds.
std::system_error Thrown when filesystem errors are encountered.

void bsa::tes3::file::read(std::span<const std::byte> a_src, copy_type a_copy = copy_type::deep)

Reads the contents of the source.

Parameters
a_src The source to read from.
a_copy The method to use when copying data from a_src.
Exceptions
binary_io::buffer_exhausted Thrown when reads index out of bounds.

void bsa::tes3::file::write(std::filesystem::path a_path) const

Parameters
a_path The path to write the archive to on the native filesystem.

void bsa::tes3::file::write(binary_io::any_ostream& a_dst) const

Parameters
a_dst The stream to write the archive to.