Archive Metadata

Because tar files require very specific formatting and stream positioning, we use the following structs to hold the metadata associated with each file.

These are largely internal objects, and shouldn’t need to be used by anybody.

Read Metadata

struct ReadMetaData

Public Members

std::string filename

The name of the file - for comparing to user requests.

size_t file_size

The size of the file (in bytes)

std::streampos data_offset

Byte offset to the file’s data in the archive.

Write Metadata

This was inherited from the original code snippet that the Archive grew out of; tar_to_stream, and is largely unchanged.

struct WriteMetaData

Container for Properties of the file to enter into the stream.

This is a touch hacky, and contains a number of hardcoded offsets of a certain size, in order to emulate the tar specification, without actually fully implementing it

Public Members

std::string const &filename

name of the file to write

std::span<std::byte const> data

the location of the file’s contents in memory

uint64_t mtime = {0u}

file modification time, in seconds since epoch

std::string filemode = {"644"}

file mode

unsigned int uid = {0u}

file owner user ID

unsigned int gid = {0u}

file owner group ID

std::string const &uname = {"root"}

file owner username

std::string const &gname = {"root"}

file owner group name