CBFS Vault 2020 Python Edition

Questions / Feedback?

set_file_compression Method

Compresses or decompresses a file or alternate stream.


def set_file_compression(file_name: str, compression: int, compression_level: int, pages_per_block: int, password: str) -> None: ...


This method changes the compression mode used to compress the file or alternate stream specified by FileName.

The value passed for FileName must be a vault-local absolute path.

The Compression parameter specifies the new compression mode to use. Valid values are:

CBFSSTORAGE_CM_NONE0Don't use compression.

CBFSSTORAGE_CM_DEFAULT1Use default compression (zlib).

CBFSSTORAGE_CM_CUSTOM2Use event-based custom compression.

Compression level is not used.

CBFSSTORAGE_CM_ZLIB3Use zlib compression.

Valid compression levels are 1-9.


Compression level is not used.

Applications that use custom compression must the on_data_compress and on_data_decompress events. Please refer to the Compression topic for more information.

The CompressionLevel parameter specifies the compression level to use, if applicable.

The PagesPerBlock parameter specifies how many pages should be compressed as a single block, if applicable. Valid values are powers of 2 up to and including 128 (i.e., 2, 4, 8, 16, 32, 64, or 128); or 0, which is interpreted as "default" (currently 16 for both zlib and RLE). Larger values allow for more efficient compression; however, since a block must be decompressed (and, for writes, recompressed) anytime its data is accessed, larger values can also cause excessive slowdown, especially for random access.

The Password parameter specifies the password to use to access the file's data, if it is encrypted.

Note: This method can only be called when active is True, and cannot be called within events.

Copyright (c) 2022 Callback Technologies, Inc. - All rights reserved.
CBFS Vault 2020 Python Edition - Version 20.0 [Build 8145]