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.

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(read_source a_source)
Reads the contents of the source.

Writing

void write(write_sink a_sink) const
Writes the contents of the object to the destination.

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.

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(read_source a_source)

Reads the contents of the source.

Parameters
a_source Where/how to read the given file.
Exceptions
binary_io::buffer_exhausted Thrown when reads index out of bounds.

void bsa::tes3::file::write(write_sink a_sink) const

Writes the contents of the object to the destination.

Parameters
a_sink Where/how to write the given file.
Exceptions
std::system_error Thrown when filesystem errors are encountered.
binary_io::buffer_exhausted Thrown when the output buffer is exhausted.