7z
This section is dedicated to the library for working with 7z archives in 1C:Enterprise, OneScript and CLI. This page describes all the actions necessary to get started
Getting Started
The library provides capabilities for working with 7z format archives: creating archives with various compression settings, extracting existing archives, working with password protection and encryption.
Key Features
Archiving Directories
The АрхивироватьКаталог function allows you to pack files from a specified directory into a 7z archive. You can specify the path to save the archive or get it as binary data.
Катало г = "C:\МойКаталог";
ПутьАрхива = "C:\Архивы\архив.7z";
Результат = OPI_7z.АрхивироватьКаталог(Каталог, ПутьАрхива);
Extracting Archives
The РазархивироватьКаталог function allows you to extract a 7z archive to a specified directory. Working with password-protected archives is supported.
ПутьАрхива = "C:\Архивы\архив.7z";
КаталогНазначения = "C:\Распаковка";
Пароль = "МойПароль123";
Результат = OPI_7z.РазархивироватьКаталог(ПутьАрхива, КаталогНазначения, Пароль);
Archiving Settings
The ПолучитьСтруктуруНастроекАрхивации function returns a structure with additional settings for creating an archive:
- password — password for archive protection
- method — compression method:
Lzma2(default),Lzma,Bzip2,Ppmd,Copy - level — compression level from 0 to 9 (default 6)
- solid — use solid archiving (single stream compression):
True/False(default) - encrypt_header — archive header encryption:
True(default when password is present)/False - threads — number of threads for LZMA2 (default 1)
- chunk_size — data chunk size when using multiple threads
- dictionary_size — dictionary size for LZMA2
- ppmd_order — model order for Ppmd method
- ppmd_memory — memory size in bytes for Ppmd method
- filters — array of preprocessing filters:
X86,PPC,IA64,ARM,ARM64,ARM_THUMB,SPARC,RISCV,DELTA - delta_distance — distance for DELTA filter (default 1)
Example of using settings:
Настройки = OPI_7z.ПолучитьСтруктуруНастроекАрхивации(Истина);
Настройки["password"] = "СекретныйПароль";
Настройки["method"] = "Lzma2";
Настройки["level"] = 9;
Настройки["encrypt_header"] = Истина;
Настройки["threads"] = 4;
Результат = OPI_7z.АрхивироватьКаталог(Каталог, ПутьАрхива, Настройки);
For maximum compression, use the Lzma2 method with compression level 9. For faster archive creation, lower the compression level or use the Copy method
When using header encryption (encrypt_header = True), file names in the archive will also be encrypted and will not be visible without entering the password