Repository navigation
BitFileCompressor
The BitFileCompressor class allows compressing files and directories.
The compressed archives can be saved to the filesystem, standard streams, or memory buffers.
| Return type | Name |
|---|---|
__init__(self, lib: bit7z_python.Bit7zLibrary, format: bit7z_python.BitInOutFormat) -> None |
|
None |
clear_password(self) -> None |
None |
compress(self, in_paths: dict[str, str], out_file: str) -> None |
None |
🚫 NOT USABLE compress(self, in_paths: dict[str, str], out_stream: std::ostream) -> None
|
None |
compress(self, in_paths: list[tuple[str, str]], out_file: str) -> None |
None |
compress(self, in_paths: list[str], out_file: str) -> None |
None |
🚫 NOT USABLE compress(self, in_paths: list[str], out_stream: std::ostream) -> None
|
None |
compress_directory(self, in_dir: str, out_file: str) -> None |
None |
compress_directory_contents(self, in_dir: str, out_file: str, recursive: bool = True, filter: str = '*') -> None |
None |
compress_file(self, in_file: str, out_file: str, input_name: str = '') -> None |
None |
compress_files(self, in_files: list[str], out_file: str) -> None |
None |
compress_files(self, in_dir: str, out_file: str, recursive: bool = True, filter: str = '*') -> None |
bit7z_python.BitOutFormat |
compression_format(self) -> bit7z_python.BitOutFormat |
bit7z_python.BitCompressionLevel |
compression_level(self) -> bit7z_python.BitCompressionLevel |
bit7z_python.BitCompressionMethod |
compression_method(self) -> bit7z_python.BitCompressionMethod |
bool |
crypt_headers(self) -> bool |
int |
dictionary_size(self) -> int |
collections.abc.Callable[[str], None] |
file_callback(self) -> collections.abc.Callable[[str], None] |
bit7z_python.BitInFormat |
format(self) -> bit7z_python.BitInFormat |
bool |
is_password_defined(self) -> bool |
bit7z_python.Bit7zLibrary |
library(self) -> bit7z_python.Bit7zLibrary |
bit7z_python.OverwriteMode |
overwrite_mode(self) -> bit7z_python.OverwriteMode |
str |
password(self) -> str |
collections.abc.Callable[[], str] |
password_callback(self) -> collections.abc.Callable[[], str] |
collections.abc.Callable[[int], bool] |
progress_callback(self) -> collections.abc.Callable[[int], bool] |
collections.abc.Callable[[int, int], None] |
ratio_callback(self) -> collections.abc.Callable[[int, int], None] |
bool |
retain_directories(self) -> bool |
None |
set_compression_level(self, level: bit7z_python.BitCompressionLevel) -> None |
None |
set_compression_method(self, method: bit7z_python.BitCompressionMethod) -> None |
None |
set_dictionary_size(self, dictionary_size: int) -> None |
None |
set_file_callback(self, callback: collections.abc.Callable[[str], None]) -> None |
None |
🚫 NOT USABLE set_format_property(self, name: wchar_t[], value: T) -> None (模板方法,计划中)
|
None |
🚫 NOT USABLE set_format_property(self, name: wchar_t[], value: T) -> None (模板方法,计划中)
|
None |
set_overwrite_mode(self, mode: bit7z_python.OverwriteMode) -> None |
None |
set_password(self, password: str) -> None |
None |
set_password(self, password: str, crypt_headers: bool) -> None (deprecated)
|
None |
set_password(self, password: str, scope: bit7z_python.EncryptionScope) -> None |
None |
set_password_callback(self, callback: collections.abc.Callable[[], str]) -> None |
None |
set_progress_callback(self, callback: collections.abc.Callable[[int], bool]) -> None |
None |
set_ratio_callback(self, callback: collections.abc.Callable[[int, int], None]) -> None |
None |
set_retain_directories(self, retain: bool) -> None |
None |
set_solid_mode(self, solid_mode: bool) -> None |
None |
set_store_creation_time(self, store_creation_time: bool) -> None |
None |
set_store_last_access_time(self, store_last_access_time: bool) -> None |
None |
set_store_last_write_time(self, store_last_write_time: bool) -> None |
None |
set_store_open_files(self, store_open_files: bool) -> None |
None |
set_store_symbolic_links(self, store_symlinks: bool) -> None |
None |
set_threads_count(self, threads_count: int) -> None |
None |
set_total_callback(self, callback: collections.abc.Callable[[int], None]) -> None |
None |
set_update_mode(self, can_update: bool) -> None (deprecated)
|
None |
set_update_mode(self, mode: bit7z_python.UpdateMode) -> None |
None |
set_volume_size(self, volume_size: int) -> None |
None |
set_word_size(self, word_size: int) -> None |
bool |
solid_mode(self) -> bool |
bool |
store_creation_time(self) -> bool |
bool |
store_last_access_time(self) -> bool |
bool |
store_last_write_time(self) -> bool |
bool |
store_open_files(self) -> bool |
bool |
store_symbolic_links(self) -> bool |
int |
threads_count(self) -> int |
collections.abc.Callable[[int], None] |
total_callback(self) -> collections.abc.Callable[[int], None] |
bit7z_python.UpdateMode |
update_mode(self) -> bit7z_python.UpdateMode |
int |
volume_size(self) -> int |
int |
word_size(self) -> int |
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.
Parameters:
- lib: the 7z library used.
- format: the output archive format.
Clear the current password used by the handler. Calling clearPassword() will disable the encryption/decryption of archives.
Note
This is equivalent to calling setPassword(L"").
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"}.
Parameters:
- in_paths: a map of paths and corresponding aliases.
- out_file: the path (relative or absolute) to the output archive file.
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"}.
Parameters:
- in_paths: a map of paths and corresponding aliases.
- out_stream: the standard ostream where to output the archive file.
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"}.
Parameters:
- in_paths: a vector of <filesystem path, in-archive path> pairs.
- out_file: the path (relative or absolute) to the output archive file.
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.
Parameters:
- in_paths: a vector of paths.
- out_file: the path (relative or absolute) to the output archive file.
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.
Parameters:
- in_paths: a vector of paths.
- out_stream: the standard ostream where the archive will be output.
Compresses an entire directory.
Note
This method is equivalent to compressFiles with filter set to L"".
Parameters:
- in_dir: the path (relative or absolute) to the input directory.
- out_file: the path (relative or absolute) to the output archive file.
def compress_directory_contents(self, in_dir: str, out_file: str, recursive: bool, filter: str) -> None: ...
Compresses the contents of a directory.
Note
Unlike compressFiles, this method includes also the metadata of the sub-folders.
Parameters:
- in_dir: the path (relative or absolute) to the input directory.
- out_file: 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.
Compresses a single file.
Parameters:
- in_file: the file to be compressed.
- out_file: the path (relative or absolute) to the output archive file.
- input_name: (optional) the name to give to the compressed file inside the output archive.
Compresses a group of files.
Note
Any path to a directory or to a not-existing file will be ignored.
Parameters:
- in_files: the path (relative or absolute) to the input files.
- out_file: the path (relative or absolute) to the output archive file.
Compresses the files contained in a directory.
Parameters:
- in_dir: the path (relative or absolute) to the input directory.
- out_file: 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.
Returns the format used for creating/updating an archive.
Returns the compression level used for creating/updating an archive.
Returns the compression method used for creating/updating an archive.
Returns whether the creator crypts also the headers of archives or not.
Returns the dictionary size used for creating/updating an archive.
Returns the current file callback.
Returns the format used for creating/updating an archive.
Returns a boolean value indicating whether a password is defined or not.
Returns the Bit7zLibrary object used by the handler.
Returns the current OverwriteMode.
Returns the password used to open, extract, or encrypt the archive.
Returns the current password callback.
Returns the current progress callback.
Returns the current ratio callback.
Returns a boolean value indicating whether the directory structure must be preserved while extracting or compressing the archive.
Sets the compression level to be used when creating/updating an archive.
Parameters:
- level: the compression level desired.
Sets the compression method to be used when creating/updating an archive.
Parameters:
- method: the compression method desired.
Sets the dictionary size to be used when creating/updating an archive.
Parameters:
- dictionary_size: the dictionary size desired.
Sets the function to be called when the current file being processed changes.
Parameters:
- callback: the file callback to be used.
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.
Parameters:
- name: The string name of the property to be set.
- value: The value to be used for the property.
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).
Parameters:
- name: The string name of the property to be set.
- value: The value to be used for the property.
Sets how the handler should behave when it tries to output to an existing file or buffer.
Parameters:
- mode: the OverwriteMode to be used by the handler.
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.
Note
Calling setPassword when the output format doesn't support archive encryption (e.g., GZip, BZip2, etc...) does not have any effects (in other words, it doesn't throw exceptions, and it has no effects on compression operations).
Note
After a password has been set, it will be used for every subsequent operation. To disable the use of the password, you need to call the clearPassword method (inherited from BitAbstractArchiveHandler), which is equivalent to setPassword(L"").
Parameters:
- password: the password to be used when creating/updating archives.
Warning
Deprecated: Since v4.1. Please use the overloaded function that takes an EncryptionScope enumerator.
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.
Note
Calling setPassword when the output format doesn't support archive encryption (e.g., GZip, BZip2, etc...) does not have any effects (in other words, it doesn't throw exceptions, and it has no effects on compression operations).
Note
Calling setPassword with "cryptHeaders" set to true does not have effects on formats different from 7z.
Note
After a password has been set, it will be used for every subsequent operation. To disable the use of the password, you need to call the clearPassword method (inherited from BitAbstractArchiveHandler), which is equivalent to setPassword(L"").
Parameters:
- password: the password to be used when creating/updating archives.
- crypt_headers: if true, the headers of the output archives will be encrypted (valid only when using the 7z format).
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.
Note
Calling setPassword when the output format doesn't support archive encryption (e.g., GZip, BZip2, etc...) does not have any effects (in other words, it doesn't throw exceptions, and it has no effects on compression operations).
Note
Using EncryptionScope::DataAndHeaders does not have effects on formats other than 7z.
Note
After a password has been set, it will be used for every subsequent operation. To disable the use of the password, you need to call the clearPassword method (inherited from BitAbstractArchiveHandler), which is equivalent to setPassword(L"").
Parameters:
- 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).
Sets the function to be called when a password is needed to complete the ongoing operation.
Parameters:
- callback: the password callback to be used.
Sets the function to be called when the processed size of the ongoing operation is updated.
Note
The completion percentage of the current operation can be obtained by calculating static_cast<int>((100.0 * processed_size) / total_size).
Parameters:
- callback: the progress callback to be used.
Sets the function to be called when the input processed size and current output size of the ongoing operation are known.
Note
The ratio percentage of a compression operation can be obtained by calculating static_cast<int>((100.0 * output_size) / input_size).
Parameters:
- callback: the ratio callback to be used.
Sets whether the operations' output will preserve the input's directory structure or not.
Parameters:
- retain: the setting for preserving or not the input directory structure
Sets whether to use solid compression or not.
Note
Setting the solid compression mode to true has effect only when using the 7z format with multiple input files.
Parameters:
- solid_mode: if true, it will be used the "solid compression" method.
Sets whether the creator will store creation timestamps of items.
Parameters:
- store_creation_time: if true, creation timestamps of items will be stored in the output archive.
Sets whether the creator will store last access timestamps of items.
Parameters:
- store_last_access_time: if true, last access timestamps of items will be stored in the output archive.
Sets whether the creator will store last write timestamps of items.
Note
By default, all archive formats store last write timestamps; pass false to suppress them.
Parameters:
- store_last_write_time: if false, last write timestamps will be omitted from the output archive.
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.
Note
On non-Windows platforms this setting has no effect.
Parameters:
- store_open_files: if true, the creator will attempt to compress files open by other processes.
Sets whether the creator will store symbolic links as links in the output archive.
Parameters:
- store_symlinks: if true, symbolic links will be stored as links.
Sets the number of threads to be used when creating/updating an archive.
Parameters:
- threads_count: the number of threads desired.
Sets the function to be called when the total size of an operation is available.
Parameters:
- callback: the total callback to be used.
Warning
Deprecated: since v4.0. It is provided just for an easier transition from the old v3 API.
Sets whether the creator can update existing archives or not.
Note
If set to false, a subsequent compression operation may throw an exception if it targets an existing archive.
Parameters:
- can_update: if true, compressing operations will update existing archives.
Sets whether and how the creator can update existing archives or not.
Note
If set to UpdateMode::None, a subsequent compression operation may throw an exception if it targets an existing archive.
Parameters:
- mode: the desired update mode.
Sets the volumeSize (in bytes) of the output archive volumes.
Note
This setting has effects only when the destination archive is on the filesystem.
Parameters:
- volume_size: The dimension of a volume.
Sets the word size to be used when creating/updating an archive.
Parameters:
- word_size: the word size desired.
Returns whether the archive creator uses solid compression or not.
Returns true if the creator has been explicitly configured to store creation timestamps of items.
Returns true if the creator has been explicitly configured to store last access timestamps of items.
Returns true if the creator has been explicitly configured to store last write timestamps of items.
Returns whether the creator will attempt to compress files that are locked by other processes.
Returns whether the archive creator stores symbolic links as links in the output archive.
Returns the number of threads used when creating/updating an archive (a zero value means that it will use the 7-zip default value).
Returns the current total callback.
Returns the update mode used when updating existing archives.
Returns the volume size (in bytes) used when creating multi-volume archives (a zero value means that all files are going in a single archive).
Returns the word size used for creating/updating an archive.