ark::archive::Archive

Defined in header “ark/archive/archive.hh”.


This class represents an archive. It effectively wraps libarchive with C++ semantics.

Methods

  • Archive(std::filesystem::path path, ArchiveMode mode)
    Constructor. Opens the archive at the given path with the specified mode.

  • Archive(core::ByteBuffer buffer)
    Constructor. Opens the archive against the given byte buffer in read mode.

  • ~Archive()
    Destructor. Closes (if not closed already) and releases any memory.

  • void close()
    Closes the file after committing any changes. Use this to avoid any potential exceptions/errors when an archive falls out of scope.

  • void write_file(const std::filesystem::path & source_path, const std::string & destination_name)
    Writes the given path to the archive, copying over its current permissions.

  • void write_content(const std::string & content, const std::string & destination_name, std::chrono::system_clock::time_point creation_time)
    Writes the given content to the archive, storing it under the destination name.

  • void extract_to(const std::filesystem::path & destination)
    Extracts all files in the archive to the given destination path.

  • core::ByteBuffer extract_entry(const std::string & source_name)
    Extracts the given path from the archive, returning it in a byte buffer.