bit7z 4.0.0
A C++ library for interfacing with the 7-zip shared libs.
|
The BitArchiveEditor class allows creating new file archives or updating old ones. More...
#include <bit7z/bitarchiveeditor.hpp>
Public Member Functions | |
BitArchiveEditor (const Bit7zLibrary &lib, const tstring &inFile, const BitInOutFormat &format, const tstring &password={}) | |
Constructs a BitArchiveEditor object, reading the given archive file path. | |
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 | applyChanges () |
Applies the requested changes (i.e., rename/update/delete operations) to the input archive. | |
void | clearPassword () noexcept |
Clear the current password used by the handler. | |
auto | compressionFormat () const noexcept -> const BitInOutFormat & |
auto | compressionLevel () const noexcept -> BitCompressionLevel |
auto | compressionMethod () const noexcept -> BitCompressionMethod |
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 | cryptHeaders () const noexcept -> bool |
void | deleteItem (const tstring &itemPath) |
Marks the item at the given path (in the archive) as deleted. | |
void | deleteItem (uint32_t index) |
Marks the item at the given index as deleted. | |
auto | dictionarySize () const noexcept -> uint32_t |
auto | fileCallback () const -> FileCallback |
auto | format () const noexcept -> const BitInFormat &override |
auto | handler () const noexcept -> const BitAbstractArchiveHandler & |
auto | isPasswordDefined () const noexcept -> bool |
auto | itemsCount () const -> uint32_t |
auto | library () const noexcept -> const Bit7zLibrary & |
auto | overwriteMode () const -> OverwriteMode |
auto | password () const -> tstring |
auto | passwordCallback () const -> PasswordCallback |
auto | progressCallback () const -> ProgressCallback |
auto | ratioCallback () const -> RatioCallback |
void | renameItem (const tstring &oldPath, const tstring &newPath) |
Requests to change the path of the item from oldPath to the newPath. | |
void | renameItem (uint32_t index, const tstring &newPath) |
Requests to change the path of the item at the specified index with the given one. | |
auto | retainDirectories () const noexcept -> bool |
void | setCompressionLevel (BitCompressionLevel level) noexcept |
Sets the compression level to be used when creating/updating an archive. | |
void | setCompressionMethod (BitCompressionMethod method) |
Sets the compression method to be used when creating/updating an archive. | |
void | setDictionarySize (uint32_t dictionarySize) |
Sets the dictionary size to be used when creating/updating an archive. | |
void | setFileCallback (const FileCallback &callback) |
Sets the function to be called when the current file being processed changes. | |
template<std::size_t N, typename T , typename = typename std::enable_if< !std::is_integral< T >::value >::type> | |
void | setFormatProperty (const wchar_t(&name)[N], const T &value) noexcept |
Sets a property for the output archive format as described by the 7-zip documentation (e.g., https://sevenzip.osdn.jp/chm/cmdline/switches/method.htm). | |
template<std::size_t N, typename T , typename = typename std::enable_if< std::is_integral< T >::value >::type> | |
void | setFormatProperty (const wchar_t(&name)[N], T value) noexcept |
Sets a property for the output archive format as described by the 7-zip documentation (e.g., https://sevenzip.osdn.jp/chm/cmdline/switches/method.htm). | |
void | setOverwriteMode (OverwriteMode mode) |
Sets how the handler should behave when it tries to output to an existing file or buffer. | |
void | setPassword (const tstring &password) override |
Sets up a password for the output archives. | |
void | setPassword (const tstring &password, bool cryptHeaders) |
Sets up a password for the output archive. | |
void | setPasswordCallback (const PasswordCallback &callback) |
Sets the function to be called when a password is needed to complete the ongoing operation. | |
void | setProgressCallback (const ProgressCallback &callback) |
Sets the function to be called when the processed size of the ongoing operation is updated. | |
void | setRatioCallback (const RatioCallback &callback) |
Sets the function to be called when the input processed size and current output size of the ongoing operation are known. | |
void | setRetainDirectories (bool retain) noexcept |
Sets whether the operations' output will preserve the input's directory structure or not. | |
void | setSolidMode (bool solidMode) noexcept |
Sets whether to use solid compression or not. | |
void | setStoreSymbolicLinks (bool storeSymlinks) noexcept |
Sets whether the creator will store symbolic links as links in the output archive. | |
void | setThreadsCount (uint32_t threadsCount) noexcept |
Sets the number of threads to be used when creating/updating an archive. | |
void | setTotalCallback (const TotalCallback &callback) |
Sets the function to be called when the total size of an operation is available. | |
void | setUpdateMode (bool canUpdate) |
Sets whether the creator can update existing archives or not. | |
void | setUpdateMode (UpdateMode mode) override |
Sets how the editor performs the update of the items in the archive. | |
void | setVolumeSize (uint64_t volumeSize) noexcept |
Sets the volumeSize (in bytes) of the output archive volumes. | |
void | setWordSize (uint32_t wordSize) |
Sets the word size to be used when creating/updating an archive. | |
auto | solidMode () const noexcept -> bool |
auto | storeSymbolicLinks () const noexcept -> bool |
auto | threadsCount () const noexcept -> uint32_t |
auto | totalCallback () const -> TotalCallback |
void | updateItem (const tstring &itemPath, const std::vector< byte_t > &inBuffer) |
Requests to update the content of the item at the specified path with the data from the given buffer. | |
void | updateItem (const tstring &itemPath, const tstring &inFile) |
Requests to update the content of the item at the specified path with the data from the given file. | |
void | updateItem (const tstring &itemPath, istream &inStream) |
Requests to update the content of the item at the specified path with the data from the given stream. | |
void | updateItem (uint32_t index, const std::vector< byte_t > &inBuffer) |
Requests to update the content of the item at the specified index with the data from the given buffer. | |
void | updateItem (uint32_t index, const tstring &inFile) |
Requests to update the content of the item at the specified index with the data from the given file. | |
void | updateItem (uint32_t index, std::istream &inStream) |
Requests to update the content of the item at the specified index with the data from the given stream. | |
auto | updateMode () const noexcept -> UpdateMode |
auto | volumeSize () const noexcept -> uint64_t |
auto | wordSize () const noexcept -> uint32_t |
The BitArchiveEditor class allows creating new file archives or updating old ones.
Update operations supported are the addition of new items, as well as renaming/updating/deleting old items;
BitArchiveEditor | ( | const Bit7zLibrary & | lib, |
const tstring & | inFile, | ||
const BitInOutFormat & | format, | ||
const tstring & | password = {} |
||
) |
Constructs a BitArchiveEditor object, reading the given archive file path.
lib | the 7z library to use. |
inFile | the path to an input archive file. |
format | the input/output archive format. |
password | (optional) the password needed to read the input archive. |
|
inherited |
Adds all the items inside the given directory path.
inDir | the directory where to search for items to be added to the output archive. |
|
inherited |
Adds the given buffer file, using the given name as a path when compressed in the output archive.
inBuffer | the buffer containing the file to be added to the output archive. |
name | user-defined path to be used inside the output archive. |
Adds the given file path, with an optional user-defined path to be used in the output archive.
inFile | 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. |
|
inherited |
Adds the given standard input stream, using the given name as a path when compressed in the output archive.
inStream | the input stream to be added. |
name | the name of the file inside the output archive. |
|
inherited |
Adds all the files in the given vector of filesystem paths.
inFiles | the vector of paths to files. |
|
inherited |
Adds all the files inside the given directory path that match the given wildcard filter.
inDir | 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. |
|
inherited |
Adds all the files inside the given directory path that match the given wildcard filter.
inDir | 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. |
policy | (optional) the filtering policy to be applied to the matched items. |
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.
inPaths | map of filesystem paths with the corresponding user-defined path desired inside the output archive. |
|
inherited |
Adds all the items that can be found by indexing the given vector of filesystem paths.
inPaths | the vector of filesystem paths. |
void applyChanges | ( | ) |
Applies the requested changes (i.e., rename/update/delete operations) to the input archive.
|
noexceptinherited |
Clear the current password used by the handler.
Calling clearPassword() will disable the encryption/decryption of archives.
|
noexceptinherited |
|
noexceptinherited |
|
noexceptinherited |
|
inherited |
Compresses all the items added to this object to the specified archive file path.
outFile | the output archive file path. |
|
inherited |
Compresses all the items added to this object to the specified buffer.
outStream | the output standard stream. |
|
inherited |
Compresses all the items added to this object to the specified buffer.
outBuffer | the output buffer. |
|
noexceptinherited |
|
noexceptinherited |
void deleteItem | ( | const tstring & | itemPath | ) |
Marks the item at the given path (in the archive) as deleted.
itemPath | the path (in the archive) of the item to be deleted. |
void deleteItem | ( | uint32_t | index | ) |
Marks the item at the given index as deleted.
index | the index of the item to be deleted. |
|
noexceptinherited |
|
inherited |
|
overridevirtualnoexceptinherited |
Implements BitAbstractArchiveHandler.
|
noexceptinherited |
|
noexceptinherited |
|
inherited |
|
noexceptinherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
Requests to change the path of the item from oldPath to the newPath.
oldPath | the old path (in the archive) of the item to be renamed. |
newPath | the new path (in the archive) desired for the item. |
void renameItem | ( | uint32_t | index, |
const tstring & | newPath | ||
) |
Requests to change the path of the item at the specified index with the given one.
index | the index of the item to be renamed. |
newPath | the new path (in the archive) desired for the item. |
|
noexceptinherited |
|
noexceptinherited |
Sets the compression level to be used when creating/updating an archive.
level | the compression level desired. |
|
inherited |
Sets the compression method to be used when creating/updating an archive.
method | the compression method desired. |
|
inherited |
Sets the dictionary size to be used when creating/updating an archive.
dictionarySize | the dictionary size desired. |
|
inherited |
Sets the function to be called when the current file being processed changes.
callback | the file callback to be used. |
|
inlinenoexceptinherited |
Sets a property for the output archive format as described by the 7-zip documentation (e.g., https://sevenzip.osdn.jp/chm/cmdline/switches/method.htm).
For example, passing the string L"tm" with a false value while creating a .7z archive will disable storing the last modified timestamps of the compressed files.
T | A non-integral type (i.e., a string). |
name | The string name of the property to be set. |
value | The value to be used for the property. |
|
inlinenoexceptinherited |
Sets a property for the output archive format as described by the 7-zip documentation (e.g., https://sevenzip.osdn.jp/chm/cmdline/switches/method.htm).
T | An integral type (i.e., a bool or an integer type). |
name | The string name of the property to be set. |
value | The value to be used for the property. |
|
inherited |
Sets how the handler should behave when it tries to output to an existing file or buffer.
mode | the OverwriteMode to be used by the handler. |
|
overridevirtualinherited |
Sets up a password for the output archives.
When setting a password, the produced archives will be encrypted using the default cryptographic method of the output format. The option "crypt headers" remains unchanged, in contrast with what happens when calling the setPassword(tstring, bool) method.
password | the password to be used when creating/updating archives. |
Reimplemented from BitAbstractArchiveHandler.
|
inherited |
Sets up a password for the output archive.
When setting a password, the produced archive will be encrypted using the default cryptographic method of the output format. If the format is 7z, and the option "cryptHeaders" is set to true, the headers of the archive will be encrypted, resulting in a password request every time the output file will be opened.
password | the password to be used when creating/updating archives. |
cryptHeaders | if true, the headers of the output archives will be encrypted (valid only when using the 7z format). |
|
inherited |
Sets the function to be called when a password is needed to complete the ongoing operation.
callback | the password callback to be used. |
|
inherited |
Sets the function to be called when the processed size of the ongoing operation is updated.
static_cast<int>((100.0 * processed_size) / total_size)
.callback | the progress callback to be used. |
|
inherited |
Sets the function to be called when the input processed size and current output size of the ongoing operation are known.
static_cast<int>((100.0 * output_size) / input_size)
.callback | the ratio callback to be used. |
|
noexceptinherited |
Sets whether the operations' output will preserve the input's directory structure or not.
retain | the setting for preserving or not the input directory structure |
|
noexceptinherited |
Sets whether to use solid compression or not.
solidMode | if true, it will be used the "solid compression" method. |
|
noexceptinherited |
Sets whether the creator will store symbolic links as links in the output archive.
storeSymlinks | if true, symbolic links will be stored as links. |
|
noexceptinherited |
Sets the number of threads to be used when creating/updating an archive.
threadsCount | the number of threads desired. |
|
inherited |
Sets the function to be called when the total size of an operation is available.
callback | the total callback to be used. |
|
inherited |
Sets whether the creator can update existing archives or not.
canUpdate | if true, compressing operations will update existing archives. |
|
overridevirtual |
Sets how the editor performs the update of the items in the archive.
mode | the desired update mode (either UpdateMode::Append or UpdateMode::Overwrite). |
Reimplemented from BitAbstractArchiveCreator.
|
noexceptinherited |
Sets the volumeSize (in bytes) of the output archive volumes.
volumeSize | The dimension of a volume. |
|
inherited |
Sets the word size to be used when creating/updating an archive.
wordSize | the word size desired. |
|
noexceptinherited |
|
noexceptinherited |
|
noexceptinherited |
|
inherited |
void updateItem | ( | const tstring & | itemPath, |
const std::vector< byte_t > & | inBuffer | ||
) |
Requests to update the content of the item at the specified path with the data from the given buffer.
itemPath | the path (in the archive) of the item to be updated. |
inBuffer | the buffer containing the new data for the item. |
Requests to update the content of the item at the specified path with the data from the given file.
itemPath | the path (in the archive) of the item to be updated. |
inFile | the path to the file containing the new data for the item. |
Requests to update the content of the item at the specified path with the data from the given stream.
itemPath | the path (in the archive) of the item to be updated. |
inStream | the stream of new data for the item. |
void updateItem | ( | uint32_t | index, |
const std::vector< byte_t > & | inBuffer | ||
) |
Requests to update the content of the item at the specified index with the data from the given buffer.
index | the index of the item to be updated. |
inBuffer | the buffer containing the new data for the item. |
void updateItem | ( | uint32_t | index, |
const tstring & | inFile | ||
) |
Requests to update the content of the item at the specified index with the data from the given file.
index | the index of the item to be updated. |
inFile | the path to the file containing the new data for the item. |
void updateItem | ( | uint32_t | index, |
std::istream & | inStream | ||
) |
Requests to update the content of the item at the specified index with the data from the given stream.
index | the index of the item to be updated. |
inStream | the stream of new data for the item. |
|
noexceptinherited |
|
noexceptinherited |
|
noexceptinherited |