bit7z 4.0.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
BitOutputArchive Class Reference

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

#include <bit7z/bitoutputarchive.hpp>

+ Inheritance diagram for BitOutputArchive:

Public Member Functions

 BitOutputArchive (const BitAbstractArchiveCreator &creator)
 Constructs a BitOutputArchive object for a completely new archive.
 
 BitOutputArchive (const BitAbstractArchiveCreator &creator, const std::vector< byte_t > &inBuffer)
 Constructs a BitOutputArchive object, opening an input file archive from the given buffer.
 
 BitOutputArchive (const BitAbstractArchiveCreator &creator, const tstring &inFile)
 Constructs a BitOutputArchive object, opening an (optional) input file archive.
 
 BitOutputArchive (const BitAbstractArchiveCreator &creator, std::istream &inStream)
 Constructs a BitOutputArchive object, reading an input file archive from the given std::istream.
 
virtual ~BitOutputArchive ()=default
 Default destructor.
 
void addDirectory (const tstring &inDir)
 Adds all the items inside the given directory path.
 
void addFile (const std::vector< byte_t > &inBuffer, const tstring &name)
 Adds the given buffer file, using the given name as a path when compressed in the output archive.
 
void addFile (const tstring &inFile, const tstring &name={})
 Adds the given file path, with an optional user-defined path to be used in the output archive.
 
void addFile (std::istream &inStream, const tstring &name)
 Adds the given standard input stream, using the given name as a path when compressed in the output archive.
 
void addFiles (const std::vector< tstring > &inFiles)
 Adds all the files in the given vector of filesystem paths.
 
void addFiles (const tstring &inDir, const tstring &filter="*", bool recursive=true)
 Adds all the files inside the given directory path that match the given wildcard filter.
 
void addFiles (const tstring &inDir, const tstring &filter="*", FilterPolicy policy=FilterPolicy::Include, bool recursive=true)
 Adds all the files inside the given directory path that match the given wildcard filter.
 
void addItems (const std::map< tstring, tstring > &inPaths)
 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.
 
void addItems (const std::vector< tstring > &inPaths)
 Adds all the items that can be found by indexing the given vector of filesystem paths.
 
void compressTo (const tstring &outFile)
 Compresses all the items added to this object to the specified archive file path.
 
void compressTo (std::ostream &outStream)
 Compresses all the items added to this object to the specified buffer.
 
void compressTo (std::vector< byte_t > &outBuffer)
 Compresses all the items added to this object to the specified buffer.
 
auto creator () const noexcept -> const BitAbstractArchiveCreator &
 
auto handler () const noexcept -> const BitAbstractArchiveHandler &
 
auto itemsCount () const -> uint32_t
 

Detailed Description

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

Constructor & Destructor Documentation

◆ BitOutputArchive() [1/4]

BitOutputArchive ( const BitAbstractArchiveCreator creator)
explicit

Constructs a BitOutputArchive object for a completely new archive.

Parameters
creatorthe reference to the BitAbstractArchiveCreator object containing all the settings to be used for creating the new archive.

◆ BitOutputArchive() [2/4]

BitOutputArchive ( const BitAbstractArchiveCreator creator,
const tstring inFile 
)
explicit

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
creatorthe reference to the BitAbstractArchiveCreator object containing all the settings to be used for creating the new archive and reading the (optional) input archive.
inFile(optional) the path to an input archive file.

◆ BitOutputArchive() [3/4]

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

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
creatorthe reference to the BitAbstractArchiveCreator object containing all the settings to be used for creating the new archive and reading the (optional) input archive.
inBufferthe buffer containing an input archive file.

◆ BitOutputArchive() [4/4]

BitOutputArchive ( const BitAbstractArchiveCreator creator,
std::istream inStream 
)

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

Parameters
creatorthe reference to the BitAbstractArchiveCreator object containing all the settings to be used for creating the new archive and reading the (optional) input archive.
inStreamthe standard input stream of the input archive file.

◆ ~BitOutputArchive()

virtual ~BitOutputArchive ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ addDirectory()

void addDirectory ( const tstring inDir)

Adds all the items inside the given directory path.

Parameters
inDirthe directory where to search for items to be added to the output archive.

◆ addFile() [1/3]

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

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

Parameters
inBufferthe buffer containing the file to be added to the output archive.
nameuser-defined path to be used inside the output archive.

◆ addFile() [2/3]

void addFile ( const tstring inFile,
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
inFilethe path to the filesystem file to be added to the output archive.
name(optional) user-defined path to be used inside the output archive.

◆ addFile() [3/3]

void addFile ( std::istream inStream,
const tstring name 
)

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

Parameters
inStreamthe input stream to be added.
namethe name of the file inside the output archive.

◆ addFiles() [1/3]

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

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

Note
Paths to directories are ignored.
Parameters
inFilesthe vector of paths to files.

◆ addFiles() [2/3]

void addFiles ( const tstring inDir,
const tstring filter = "*",
bool  recursive = true 
)

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

Parameters
inDirthe 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.

◆ addFiles() [3/3]

void addFiles ( const tstring inDir,
const tstring filter = "*",
FilterPolicy  policy = FilterPolicy::Include,
bool  recursive = true 
)

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

Parameters
inDirthe 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.
policy(optional) the filtering policy to be applied to the matched items.

◆ addItems() [1/2]

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

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
inPathsmap of filesystem paths with the corresponding user-defined path desired inside the output archive.

◆ addItems() [2/2]

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

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

Parameters
inPathsthe vector of filesystem paths.

◆ compressTo() [1/3]

void compressTo ( const tstring outFile)

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 outFile path parameter, the file will be updated.
Parameters
outFilethe output archive file path.

◆ compressTo() [2/3]

void compressTo ( std::ostream outStream)

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

Parameters
outStreamthe output standard stream.

◆ compressTo() [3/3]

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

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

Parameters
outBufferthe output buffer.

◆ creator()

auto creator ( ) const -> const BitAbstractArchiveCreator &
noexcept
Returns
a constant reference to the BitAbstractArchiveHandler object containing the settings for writing the output archive.

◆ handler()

auto handler ( ) const -> const BitAbstractArchiveHandler &
noexcept
Returns
a constant reference to the BitAbstractArchiveHandler object containing the settings for writing the output archive.

◆ itemsCount()

auto itemsCount ( ) const -> uint32_t
Returns
the total number of items added to the output archive object.

The documentation for this class was generated from the following file: