SevenZipComponent

7-Zip. File archiver with high compression ratio - www.7-zip.org

[ v0.12.6+ ]

Configuration

Available compression methods

Value Description
Deflate Combination of the LZ77 algorithm and Huffman coding [?]
Deflate64 A slightly higher compression ratio and lower compression time (increased dictionary size - 64kB) [?]
BZip2 More effectively than Deflate, but is considerably slower [?]
Lzma A high compression ratio than bzip2. Uses dictionary (improved variant of LZ77 + range encoding) and special handling of binary data [?]
Lzma2 Efficient multithreaded compression/decompression + improved compression of partially or completely incompressible files. [?]
Ppmd Adaptive statistical data compression. Based on context modeling and prediction. [?]
Copy Without compression algorithm.

Available compression levels

Value Description
0 None
1 Fast
2 Low
3 Normal
4 High
5 Ultra (Maximum)

Available types of archive

Format Typically extension of file +Methods Description
SevenZip .7z Lzma, Lzma2, Ppmd, BZip2, Copy Original format of the 7-Zip archiver. May contain one or more files/directories. May use different compression algorithms (Lzma/Lzma2 is the most common). But it can't store filesystem permissions (Unix owner/group permissions etc.) [?]
Zip .zip Deflate, Deflate64, BZip2, Lzma, Ppmd, Copy May contain one or more files/directories. May use different compression algorithms (Deflate is the most common). [?]
GZip .tar.gz or .tgz Deflate Based on the Deflate algorithm. To compress only single files. [?]
BZip2 .tar.bz2 BZip2 Based on the BZip2 algorithm. To compress only single files. [?]
Tar .tar Copy For collecting many files into one archive file. Contains uncompressed byte streams of the files. [?]
XZ .tar.xz or .txz Lzma2 Incorporates the Lzma2 compression algorithm. Supports Unix-like file system metadata. [?]

pack

Packing with 7-zip engine.

#[7z pack]

files

To compress selected files with default settings.

void pack.files(object files, string output [, object except][, enum format, enum method, integer level])
Argument Value by default
format Zip
method Deflate
level 3 (Normal)

Individual signatures:

void pack.files(object files, string output)
void pack.files(object files, string output, object except)
void pack.files(object files, string output, enum format, enum method, integer level)
void pack.files(object files, string output, object except, enum format, enum method, integer level)

Arguments:

  • files - List of files as {"f1", "path\*.dll", ..}. May contain file mask.
  • output - Archive name.
  • except - List of files to exclude from input list. May contain file mask.
    • requires path to file as it presented for input list, for example: { "$(dir)*.iobj", "$(dir)/rel/*.*" }
  • format - Type of archive: SevenZip, Zip, GZip, BZip2, Tar, XZ
  • method - Compression method: Copy, Deflate, Deflate64, BZip2, Lzma, Lzma2, Ppmd
  • level - Compression level: 0 (None) to 5 (Maximum)

Samples:

#[7z pack.files({"IntelOCL.log", "IntelChipset.log"}, "ilog.7z")]
#[7z pack.files({"bin\gpp.exe", "bin\lib\*.dll"}, "gpp.7z", {"bin\lib\stub.dll"}, SevenZip, Lzma2, 4)]
#[7z pack.files({"C:\Intel\Logs\IntelAMT.log"}, "P:\s01\CodeAnalysisLog.xml"}, "D:\output.zip", Zip, Deflate, 2)]
#[7z pack.files({"bin\xscale.exe", "bin\libintl-8.dll"}, "xscale.tar", Tar, Copy, 0)]
#[7z pack.files({"xscale.tar"}, "xscale.tar.xz", XZ, Lzma2, 4)]

Notes:

  • The solution directory is path by default for all input & output files.
  • The \ as path separator is used for relative structure of directories in the final archive.
  • The / as path separator is used for absolute structure of directories in the final archive.
#[7z pack.files({ "$(path)bin\Debug\subdir\File3.dll", "$(path)bin\Debug\File1.dll", "$(path)bin\Debug\File2.dll" }, "$(output)Archive1.zip")]

The final Archive1.zip will be:

│   File1.dll
│   File2.dll
│
└───subdir
        File3.dll
#[7z pack.files({ "$(path)bin/Debug/subdir/File3.dll", "$(path)bin/Debug/File1.dll", "$(path)bin/Debug/File2.dll" }, "$(output)Archive2.zip")]

The final Archive2.zip will be:

└───bin
    └───Debug
        │   File1.dll
        │   File2.dll
        │
        └───subdir
                File3.dll

directory

To compress selected directory with default settings.

void pack.directory(string dir, string output [, enum format, enum method, integer level])

Individual signatures:

void pack.directory(string dir, string output)
void pack.directory(string dir, string output, enum format, enum method, integer level)

Arguments:

  • dir - Path to directory for packing.
  • output - Archive name.
  • format - Type of archive: SevenZip, Zip, GZip, BZip2, Tar, XZ
  • method - Compression method: Copy, Deflate, Deflate64, BZip2, Lzma, Lzma2, Ppmd
  • level - Compression level: 0 (None) to 5 (Maximum)

Samples:

#[7z pack.directory("bin", "release.zip")]
#[7z pack.directory("D:\log", "log.7z", SevenZip, Lzma2, 4)]

check

#[7z check]

Method:

Verification data of archive. Returns true if no any errors for archive.

boolean check(string file [, string pwd])

Individual signatures:

boolean check(string file)
boolean check(string file, string pwd)

Arguments:

  • file - Archive for testing.
  • pwd - Password of archive if requires.

Samples:

#[( !#[7z check("arch.tar.xz")] ){
    #[Build cancel = true]
}]
#[var arch = #[7z check("arch.tar.xz", "pass-123")]]

unpack

Method:

Extract archive data.

void unpack(string file [, string output][, boolean delete][, string pwd])

Individual signatures

Extract archive data into same directory:

void unpack(string file)

Extract archive data into selected directory:

void unpack(string file, string output)

Extract data from protected archive into selected directory:

void unpack(string file, string output, string pwd)

Extract archive data into selected directory and delete it after extraction if needed:

void unpack(string file, string output, boolean delete)

Extract data from protected archive into selected directory and delete it after extraction if needed:

void unpack(string file, string output, boolean delete, string pwd)

Extract archive data into same directory and delete it after extraction if needed:

void unpack(string file, boolean delete)

Extract data from protected archive into same directory and delete it after extraction if needed:

void unpack(string file, boolean delete, string pwd)

Arguments:

  • file - Archive for unpacking.
  • output - Output path to unpacking archive data.
  • delete - To delete archive after extraction if true.
  • pwd - Password of archive.

Samples:

#[7z unpack("release.7z", true)]
#[7z unpack("xscale.zip", "D:\app\xscale", false, "pass-123")]

References