|
bit7z 4.1.0
A C++ library for interfacing with the 7-zip shared libs.
|
The BitFileCompressor class allows compressing files and directories. More...
#include <bit7z/bitfilecompressor.hpp>
Public Member Functions | |
| BitFileCompressor (const Bit7zLibrary &lib, const BitInOutFormat &format) | |
| Constructs a BitFileCompressor object. | |
| void | clearPassword () noexcept |
| Clear the current password used by the handler. | |
| void | compress (const std::map< tstring, tstring > &inPaths, const tstring &outFile) const |
| Compresses the given files or directories using the specified aliases. | |
| void | compress (const std::map< tstring, tstring > &inPaths, std::ostream &outStream) const |
| Compresses the given files or directories using the specified aliases. | |
| void | compress (const std::vector< std::pair< tstring, tstring > > &inPaths, const tstring &outFile) const |
| Compresses the given files or directories using the specified aliases. | |
| void | compress (const std::vector< tstring > &inPaths, const tstring &outFile) const |
| Compresses the given files or directories. | |
| void | compress (const std::vector< tstring > &inPaths, std::ostream &outStream) const |
| Compresses the given files or directories. | |
| void | compressDirectory (const tstring &inDir, const tstring &outFile) const |
| Compresses an entire directory. | |
| void | compressDirectoryContents (const tstring &inDir, const tstring &outFile, bool recursive=true, const tstring &filter="*") const |
| Compresses the contents of a directory. | |
| void | compressFile (const tstring &inFile, const tstring &outFile, const tstring &inputName={}) const |
| Compresses a single file. | |
| void | compressFiles (const std::vector< tstring > &inFiles, const tstring &outFile) const |
| Compresses a group of files. | |
| void | compressFiles (const tstring &inDir, const tstring &outFile, bool recursive=true, const tstring &filter="*") const |
| Compresses the files contained in a directory. | |
| auto | compressionFormat () const noexcept -> const BitInOutFormat & |
| auto | compressionLevel () const noexcept -> BitCompressionLevel |
| auto | compressionMethod () const noexcept -> BitCompressionMethod |
| auto | cryptHeaders () const noexcept -> bool |
| auto | dictionarySize () const noexcept -> std::uint32_t |
| auto | fileCallback () const -> const FileCallback & |
| auto | format () const noexcept -> const BitInFormat &override |
| auto | isPasswordDefined () const noexcept -> bool |
| auto | library () const noexcept -> const Bit7zLibrary & |
| auto | overwriteMode () const noexcept -> OverwriteMode |
| auto | password () const -> const tstring & |
| auto | passwordCallback () const -> const PasswordCallback & |
| auto | progressCallback () const -> const ProgressCallback & |
| auto | ratioCallback () const -> const RatioCallback & |
| 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 (std::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. | |
| 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). | |
| 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 | setPassword (const tstring &password, EncryptionScope scope) |
| Sets up a password for the output archive, specifying the encryption scope. | |
| 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 | setStoreCreationTime (bool storeCreationTime) noexcept |
| Sets whether the creator will store creation timestamps of items. | |
| void | setStoreLastAccessTime (bool storeLastAccessTime) noexcept |
| Sets whether the creator will store last access timestamps of items. | |
| void | setStoreLastWriteTime (bool storeLastWriteTime) noexcept |
| Sets whether the creator will store last write timestamps of items. | |
| void | setStoreOpenFiles (bool storeOpenFiles) noexcept |
| Sets whether the creator will attempt to compress files that are locked by other processes. | |
| void | setStoreSymbolicLinks (bool storeSymlinks) noexcept |
| Sets whether the creator will store symbolic links as links in the output archive. | |
| void | setThreadsCount (std::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. | |
| virtual void | setUpdateMode (UpdateMode mode) |
| Sets whether and how the creator can update existing archives or not. | |
| void | setVolumeSize (std::uint64_t volumeSize) noexcept |
| Sets the volumeSize (in bytes) of the output archive volumes. | |
| void | setWordSize (std::uint32_t wordSize) |
| Sets the word size to be used when creating/updating an archive. | |
| auto | solidMode () const noexcept -> bool |
| auto | storeCreationTime () const noexcept -> bool |
| auto | storeLastAccessTime () const noexcept -> bool |
| auto | storeLastWriteTime () const noexcept -> bool |
| auto | storeOpenFiles () const noexcept -> bool |
| auto | storeSymbolicLinks () const noexcept -> bool |
| auto | threadsCount () const noexcept -> std::uint32_t |
| auto | totalCallback () const -> const TotalCallback & |
| auto | updateMode () const noexcept -> UpdateMode |
| auto | volumeSize () const noexcept -> std::uint64_t |
| auto | wordSize () const noexcept -> std::uint32_t |
The BitFileCompressor class allows compressing files and directories.
The compressed archives can be saved to the filesystem, standard streams, or memory buffers.
It let decide various properties of the produced archive, such as the password protection and the compression level desired.
| BitFileCompressor | ( | const Bit7zLibrary & | lib, |
| const BitInOutFormat & | format ) |
Constructs a BitFileCompressor object.
The Bit7zLibrary parameter is needed to have access to the functionalities of the 7z DLLs. On the contrary, the BitInOutFormat is required to know the format of the output archive.
| lib | the 7z library used. |
| format | the output archive format. |
|
noexceptinherited |
Clear the current password used by the handler.
Calling clearPassword() will disable the encryption/decryption of archives.
Compresses the given files or directories using the specified aliases.
The items in the first argument must be the relative or absolute paths to files or directories existing on the filesystem. Each pair in the map must follow the following format: {"path to file in the filesystem", "alias path in the archive"}.
| inPaths | a map of paths and corresponding aliases. |
| outFile | the path (relative or absolute) to the output archive file. |
| void compress | ( | const std::map< tstring, tstring > & | inPaths, |
| std::ostream & | outStream ) const |
Compresses the given files or directories using the specified aliases.
The items in the first argument must be the relative or absolute paths to files or directories existing on the filesystem. Each pair in the map must follow the following format: {"path to file in the filesystem", "alias path in the archive"}.
| inPaths | a map of paths and corresponding aliases. |
| outStream | the standard ostream where to output the archive file. |
| void compress | ( | const std::vector< std::pair< tstring, tstring > > & | inPaths, |
| const tstring & | outFile ) const |
Compresses the given files or directories using the specified aliases.
The items in the first argument must be the relative or absolute paths to files or directories existing on the filesystem. Each pair in the vector must follow the following format: {"path to file in the filesystem", "alias path in the archive"}.
| inPaths | a vector of <filesystem path, in-archive path> pairs. |
| outFile | the path (relative or absolute) to the output archive file. |
| void compress | ( | const std::vector< tstring > & | inPaths, |
| const tstring & | outFile ) const |
Compresses the given files or directories.
The items in the first argument must be the relative or absolute paths to files or directories existing on the filesystem.
| inPaths | a vector of paths. |
| outFile | the path (relative or absolute) to the output archive file. |
| void compress | ( | const std::vector< tstring > & | inPaths, |
| std::ostream & | outStream ) const |
Compresses the given files or directories.
The items in the first argument must be the relative or absolute paths to files or directories existing on the filesystem.
| inPaths | a vector of paths. |
| outStream | the standard ostream where the archive will be output. |
Compresses an entire directory.
| inDir | the path (relative or absolute) to the input directory. |
| outFile | the path (relative or absolute) to the output archive file. |
| void compressDirectoryContents | ( | const tstring & | inDir, |
| const tstring & | outFile, | ||
| bool | recursive = true, | ||
| const tstring & | filter = "*" ) const |
Compresses the contents of a directory.
| inDir | the path (relative or absolute) to the input directory. |
| outFile | the path (relative or absolute) to the output archive file. |
| recursive | (optional) if true, it searches the contents inside the sub-folders of inDir. |
| filter | (optional) the filter to use when searching the contents inside inDir. |
|
inlineinherited |
Compresses a single file.
| inFile | the file to be compressed. |
| outFile | the path (relative or absolute) to the output archive file. |
| inputName | (optional) the name to give to the compressed file inside the output archive. |
| void compressFiles | ( | const std::vector< tstring > & | inFiles, |
| const tstring & | outFile ) const |
Compresses a group of files.
| inFiles | the path (relative or absolute) to the input files. |
| outFile | the path (relative or absolute) to the output archive file. |
| void compressFiles | ( | const tstring & | inDir, |
| const tstring & | outFile, | ||
| bool | recursive = true, | ||
| const tstring & | filter = "*" ) const |
Compresses the files contained in a directory.
| inDir | the path (relative or absolute) to the input directory. |
| outFile | the path (relative or absolute) to the output archive file. |
| recursive | (optional) if true, it searches files inside the subfolders of inDir. |
| filter | (optional) the filter to use when searching files inside inDir. |
|
noexceptinherited |
|
noexceptinherited |
|
noexceptinherited |
|
noexceptinherited |
|
noexceptinherited |
|
inherited |
|
overridenoexceptinherited |
|
noexceptinherited |
|
noexceptinherited |
|
noexceptinherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
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. |
|
overrideinherited |
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. |
|
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 up a password for the output archive, specifying the encryption scope.
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 scope is EncryptionScope::DataAndHeaders, the archive headers will also 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. |
| scope | the scope of encryption; use EncryptionScope::DataAndHeaders to also encrypt the archive headers (valid only for 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.
| 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.
| 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 creation timestamps of items.
| storeCreationTime | if true, creation timestamps of items will be stored in the output archive. |
|
noexceptinherited |
Sets whether the creator will store last access timestamps of items.
| storeLastAccessTime | if true, last access timestamps of items will be stored in the output archive. |
|
noexceptinherited |
Sets whether the creator will store last write timestamps of items.
| storeLastWriteTime | if false, last write timestamps will be omitted from the output archive. |
|
noexceptinherited |
Sets whether the creator will attempt to compress files that are locked by other processes.
When enabled, the creator opens files with shared read/write access on Windows, which is equivalent to 7-zip's -ssw switch. This allows compressing files that another process has open for writing.
| storeOpenFiles | if true, the creator will attempt to compress files open by other processes. |
|
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. |
|
virtualinherited |
Sets whether and how the creator can update existing archives or not.
| mode | the desired update mode. |
|
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 |
|
noexceptinherited |
|
noexceptinherited |
|
noexceptinherited |
|
noexceptinherited |
|
inherited |
|
noexceptinherited |
|
noexceptinherited |
|
noexceptinherited |