TarWriter

class TarWriter

Writes a POSIX ustar archive, readable by any standard tar tool.

Entries are regular files, added one at a time. Names longer than 100 characters are split over the ustar prefix and name fields; names that do not fit even then are rejected. The archive is finished by close or the destructor.

Public Functions

explicit TarWriter(const std::string &file_name)

Create (or truncate) the archive at file_name.

TarWriter(const TarWriter&) = delete
TarWriter &operator=(const TarWriter&) = delete
~TarWriter()
void add(const std::string &name, const char *data, std::size_t size)

Append a file called name with the given contents.

void close()

Write the end-of-archive marker and close the file.