TarReader

class TarReader

Reads the regular files of a tar archive (ustar or GNU, as written by standard tools).

The archive is indexed when opened; entries are then read by name. Entries other than regular files are skipped, and long names stored in GNU or pax extension headers are not interpreted.

Public Functions

explicit TarReader(const std::string &file_name)

Open and index the archive at file_name.

std::vector<std::string> names() const

The names of all files in the archive, in sorted order.

bool contains(const std::string &name) const

Whether the archive contains a file called name.

std::size_t size(const std::string &name) const

The size in bytes of the file called name.

void read(const std::string &name, char *data)

Read the file called name into data, which must hold size(name) bytes.

std::vector<char> read(const std::string &name)

The contents of the file called name.