Skip to content

BitOutputArchive

Oz edited this page Jan 20, 2023 · 7 revisions

The BitOutputArchive class, given a creator object, allows creating new archives.

#include <bit7z/bitoutputarchive.hpp>

List of all members

Public Members

Return type Name
BitOutputArchive( const BitAbstractArchiveCreator& creator )
BitOutputArchive( const BitAbstractArchiveCreator& creator, const tstring& in_file )
BitOutputArchive( const BitAbstractArchiveCreator& creator, const std::vector< byte_t >& in_buffer )
BitOutputArchive( const BitAbstractArchiveCreator& creator, std::istream& in_stream )
void addItems( const std::vector< tstring >& in_paths )
void addItems( const std::map< tstring, tstring >& in_paths )
void addFile( const tstring& in_file, const tstring& name = {} )
void addFile( const std::vector< byte_t >& in_buffer, const tstring& name )
void addFile( std::istream& in_stream, const tstring& name )
void addFiles( const std::vector< tstring >& in_files )
void addFiles( const tstring& in_dir, const tstring& filter = ".", bool recursive = true )
void addDirectory( const tstring& in_dir )
void compressTo( const tstring& out_file )
void compressTo( std::vector< byte_t >& out_buffer )
void compressTo( std::ostream& out_stream )
uint32_t itemsCount() const
const BitAbstractArchiveHandler & handler() const noexcept
~BitOutputArchive() = default

Member Function Documentation

BitOutputArchive( const BitAbstractArchiveCreator& creator )

Constructs a BitOutputArchive object for a completely new archive.

Parameters:

  • creator: the reference to the BitAbstractArchiveCreator object containing all the settings to be used for creating the new archive.

BitOutputArchive( const BitAbstractArchiveCreator& creator, const tstring& in_file )

Constructs a BitOutputArchive object, opening an (optional) input file archive. If a non-empty input file path is passed, the corresponding archive will be opened and used as a base for the creation of the new archive. Otherwise, the class will behave as if it is creating a completely new archive.

Parameters:

  • creator: the reference to the BitAbstractArchiveCreator object containing all the settings to be used for creating the new archive and reading the (optional) input archive.
  • in_file: (optional) the path to an input archive file.

BitOutputArchive( const BitAbstractArchiveCreator& creator, const std::vector< byte_t >& in_buffer )

Constructs a BitOutputArchive object, opening an input file archive from the given buffer. If a non-empty input buffer is passed, the archive file it contains will be opened and used as a base for the creation of the new archive. Otherwise, the class will behave as if it is creating a completely new archive.

Parameters:

  • creator: the reference to the BitAbstractArchiveCreator object containing all the settings to be used for creating the new archive and reading the (optional) input archive.
  • in_buffer: the buffer containing an input archive file.

BitOutputArchive( const BitAbstractArchiveCreator& creator, std::istream& in_stream )

Constructs a BitOutputArchive object, reading an input file archive from the given std::istream.

Parameters:

  • creator: the reference to the BitAbstractArchiveCreator object containing all the settings to be used for creating the new archive and reading the (optional) input archive.
  • in_stream: the standard input stream of the input archive file.

void addItems( const std::vector< tstring >& in_paths )

Adds all the items that can be found by indexing the given vector of filesystem paths.

Parameters:

  • in_paths: the vector of filesystem paths.

void addItems( const std::map< tstring, tstring >& in_paths )

Adds all the items that can be found by indexing the keys of the given map of filesystem paths; the corresponding mapped values are the user-defined paths wanted inside the output archive.

Parameters:

  • in_paths: map of filesystem paths with the corresponding user-defined path desired inside the output archive.

void addFile( const tstring& in_file, const tstring& name = {} )

Adds the given file path, with an optional user-defined path to be used in the output archive.

Note: If a directory path is given, a BitException is thrown.

Parameters:

  • in_file: the path to the filesystem file to be added to the output archive.
  • name: (optional) user-defined path to be used inside the output archive.

void addFile( const std::vector< byte_t >& in_buffer, const tstring& name )

Adds the given buffer file, using the given name as a path when compressed in the output archive.

Parameters:

  • in_buffer: the buffer containing the file to be added to the output archive.
  • name: user-defined path to be used inside the output archive.

void addFile( std::istream& in_stream, const tstring& name )

Adds the given standard input stream, using the given name as a path when compressed in the output archive.

Parameters:

  • in_stream:
  • name:

void addFiles( const std::vector< tstring >& in_files )

Adds all the files in the given vector of filesystem paths.

Note: Paths to directories are ignored.

Parameters:

  • in_files: the vector of paths to files.

void addFiles( const tstring& in_dir, const tstring& filter = ".", bool recursive = true )

Adds all the files inside the given directory path that match the given wildcard filter.

Parameters:

  • in_dir: the directory where to search for files to be added to the output archive.
  • filter: (optional) the wildcard filter to be used for searching the files.
  • recursive: (optional) recursively search the files in the given directory and all of its subdirectories.

void addDirectory( const tstring& in_dir )

Adds all the items inside the given directory path.

Parameters:

  • in_dir: the directory where to search for items to be added to the output archive.

void compressTo( const tstring& out_file )

Compresses all the items added to this object to the specified archive file path.

Note: If this object was created by passing an input archive file path, and this latter is the same as the out_file path parameter, the file will be updated.

Parameters:

  • out_file: the output archive file path.

void compressTo( std::vector< byte_t >& out_buffer )

Compresses all the items added to this object to the specified buffer.

Parameters:

  • out_buffer: the output buffer.

void compressTo( std::ostream& out_stream )

Compresses all the items added to this object to the specified buffer.

Parameters:

  • out_stream: the output standard stream.

uint32_t itemsCount() const

Returns the total number of items added to the output archive object.

const BitAbstractArchiveHandler & handler() const noexcept

Returns a constant reference to the BitAbstractArchiveHandler object containing the settings for writing the output archive.

[virtual] ~BitOutputArchive() = default

Default destructor.

Clone this wiki locally