All Projects → wqweto → VszLib

wqweto / VszLib

Licence: LGPL-3.0 license
7-zip VB6 Helper

Programming Languages

vba
158 projects

Projects that are alternatives of or similar to VszLib

ZipArchive
A single-class pure VB6 library for zip with ASM speed
Stars: ✭ 38 (+8.57%)
Mutual labels:  compression, zip, vb6
Peazip
Free Zip / Unzip software and Rar file extractor. Cross-platform file and archive manager. Features volume spanning, compression, authenticated encryption. Supports 7Z, 7-Zip sfx, ACE, ARJ, Brotli, BZ2, CAB, CHM, CPIO, DEB, GZ, ISO, JAR, LHA/LZH, NSIS, OOo, PAQ/LPAQ, PEA, QUAD, RAR, RPM, split, TAR, Z, ZIP, ZIPX, Zstandard.
Stars: ✭ 827 (+2262.86%)
Mutual labels:  compression, zip
qlZipInfo
MacOSX QuickLook Generator for zip, jar, tar, tar.gz (.tgz), tar.bz2 (.tbz2/.tbz), tar.Z. xar (.xar, .pkg), debian (.deb), RedHat Package Manager (.rpm), 7zip (.7z), xz, Microsoft cabinet (.cab), gzip (.gz), lha, BinHex 4.0 (.hqx), and Stuffit (.sit) archives, and ISO9660 images
Stars: ✭ 47 (+34.29%)
Mutual labels:  compression, zip
Zippy
Pure Nim implementation of deflate, zlib, gzip and zip.
Stars: ✭ 88 (+151.43%)
Mutual labels:  compression, zip
Zip
A portable, simple zip library written in C
Stars: ✭ 596 (+1602.86%)
Mutual labels:  compression, zip
Leanify
lightweight lossless file minifier/optimizer
Stars: ✭ 694 (+1882.86%)
Mutual labels:  compression, zip
Zip
Efficient library for manipulating zip archives
Stars: ✭ 69 (+97.14%)
Mutual labels:  compression, zip
lzbase62
LZ77(LZSS) based compression algorithm in base62 for JavaScript.
Stars: ✭ 38 (+8.57%)
Mutual labels:  compression, zip
Zipstorer
A Pure C# Class to Store Files in Zip
Stars: ✭ 139 (+297.14%)
Mutual labels:  compression, zip
Bit7z
A C++ static library offering a clean and simple interface to the 7-zip DLLs.
Stars: ✭ 159 (+354.29%)
Mutual labels:  compression, zip
Zip
Swift framework for zipping and unzipping files.
Stars: ✭ 2,120 (+5957.14%)
Mutual labels:  compression, zip
Libzip
A C library for reading, creating, and modifying zip archives.
Stars: ✭ 379 (+982.86%)
Mutual labels:  compression, zip
Gulp Zip
ZIP compress files
Stars: ✭ 262 (+648.57%)
Mutual labels:  compression, zip
Minizip Ng
Fork of the popular zip manipulation library found in the zlib distribution.
Stars: ✭ 750 (+2042.86%)
Mutual labels:  compression, zip
Compress
Optimized Go Compression Packages
Stars: ✭ 2,478 (+6980%)
Mutual labels:  compression, zip
Zipper
🗳A library to create, read and modify ZIP archive files, written in Swift.
Stars: ✭ 38 (+8.57%)
Mutual labels:  compression, zip
PLzmaSDK
PLzmaSDK is (Portable, Patched, Package, cross-P-latform) Lzma SDK.
Stars: ✭ 28 (-20%)
Mutual labels:  compression, lzma
EasyCompressor
⚡ A compression library that implements many compression algorithms such as LZ4, Zstd, LZMA, Snappy, Brotli, GZip, and Deflate. It helps you to improve performance by reducing Memory Usage and Network Traffic for caching.
Stars: ✭ 167 (+377.14%)
Mutual labels:  compression, lzma
Sharpcompress
SharpCompress is a fully managed C# library to deal with many compression types and formats.
Stars: ✭ 1,397 (+3891.43%)
Mutual labels:  compression, zip
Datacompression
Swift libcompression wrapper as an extension for the Data type (GZIP, ZLIB, LZFSE, LZMA, LZ4, deflate, RFC-1950, RFC-1951, RFC-1952)
Stars: ✭ 191 (+445.71%)
Mutual labels:  compression, zip

VszLib

(Vsz = Vb Seven Zip)

7-zip SDK supports several compression methods that can produce and read 7z, zip, gzip, tar, bzip2 and other archives. This is a VB6 helper component that makes using original 7z.dll in your VB6 projects possible.

Simple compress

With New cVszArchive
    .AddFile "your_file"
    .CompressArchive "test.7z"
End With

Extract

With New cVszArchive
    .OpenArchive "test.7z"
    .Extract "extract_folder"
End With

Create zip file with unicode filenames

With New cVszArchive
    .AddFile "your_file"
    '--- store filenames in UTF-8
    .Parameter("cu") = "on"
    .CompressArchive "archive.zip"
End With

More options

With New cVszArchive
    .AddFile "your_file"
    .AddFile "folder\another_file", "folder\name_in_archive"
    '--- fast compression (-mx3)
    .Parameter("x") = 3 
    '--- LZMA2 method supports multi-core compression
    .Parameter("0") = "LZMA2"
    .Parameter("mt") = "on"
    .Password = "secret"
    '--- split in 10MB volumes
    .VolumeSize = 10# * 1024 * 1024
    .CompressArchive "test_lzma2.7z"
End With

With New cVszArchive
    .OpenArchive "source.7z"
    .Extract "bin_folder", "*.exe"
End With

Using source

Before opening Src\VszLib.vbp register Src\SevenZip.tlb with regtlib.exe, VB6 IDE or your favorite typelib registration tool. You don't need to redistribute SevenZip.tlb, it's only needed in development environment.

Using component

Register Bin\VszLib.dll with regsvr32.exe (or VB6 IDE) and add a reference (Project | References...) in your project to 7-zip VB6 Helper 1.0. You only need to redistribute Bin\VszLib.dll with your application, pdb files are needed only for debugging purposes. Note that Bin\VszLib.dll is compiled with line numbers in the source so that error logging can produce more useful traces.

API

The only publicly accessible class in the library is cVszArchive. Here is a short description of the methods, properties and events in order of relevance (kind of).

Init([DllFile As String]) As Boolean

Optionally used to indicate 7z.dll location. If DllFile is empty first 7z.dll is loaded from VszLib.dll folder, then registry is inspected for 7-zip setup folder, finally lightweight 7za.dll is attempt loaded from VszLib.dll folder. Best practice is to place 7z.dll next to VszLib.dll and to not call Init explicitly from client code. Extract/compress operation will call it if needed.

Note that 7za.dll (from 7-zip extras) can be used to compress/extract only 7z archives (no zip support). The even smaller 7zxa.dll (172KB) can be used to only extract 7z archives.

OpenArchive(ArchiveFile As String) As Boolean

Opens the archive using archive file extension to guess decompressor type. Currently supported file extension for update: 7z, zip, tar, bz2, gz, xz, wim. Other formats supported: rar, cab, chm, iso, msi, hfs, iso, arj, cpio, deb, dmg, fat, flv, lzh, lzma, lzma86, mbr, ntfs, exe, pmd, rpm, 001, swf, vhd, xar, z. Populates FileCount and FileInfo properties.

Extract(TargetFolder As String, [Filter]) As Boolean

Extracts files to TargetFolder from a previously opened archive file. Optional Filter can specify which file entries to extract by exact match (document.txt), a filename mask (*.exe) or an array of FileCount booleans, each index indicating whether to decompress the file with same index (array entry set to True) or to skip it (array entry set to False). Raises Progress event to indicate progress and to allow cancellation of the extraction.

Property FileCount As Long (read-only)

Returns number of file entries in the archive

Property FileInfo(FileIdx As Long) (read-only)

Returns an array with information about a file entry. Array indexes are: 0 - file name, 1 - attributes, 2 - size, 3 - bool if encrypted, 4 - CRC, 5 - file comment, 6 - creation time, 7 - last access time, 8 - last write time. Some of the entries can be Empty if not supported by the current archive format.

AddFile(File As String, [Name As String], [Comment As String]) As Boolean

Adds a file to archive. File must be an (absolute) path to an existing file. Optional Name can specify name and relative folder in the archive the entry is going to be stored to. If Name not specified, filename portion of File is used as name in the root folder of the archive. Comment is optional and (probably) not supported by all compressors.

CompressArchive(ArchiveFile As String) As Boolean

Creates an archive using previously added files. Compressor type is guessed by archive file extension. Raises Progress event to indicate progress and to allow cancellation of the compression.

Property Parameter(ParamName As String) As Variant (read/write)

Specifies custom compression parameters. These correspond to -m switch of command line 7z.exe. Setting compression level switch -mx3 or -mx=3 is translated to Parameter("x") = 3. Setting 7z compression method -m0=LZMA2 is translated to Parameter("0") = "LZMA2". Setting multi-threading switch -mmt=on or -mmt=3 is translated to Parameter("mt") = "on" or Parameter("mt") = 3. Setting encrypt headers switch -mhe=on is translated to Parameter("he") = "on". See more examples of -m switch for additional info.

Property Password As String (read/write)

Gets/sets password used during extraction/compression. If incorrect archive password is using, decompressor raises Data Error. Wrong password? error through Error event.

Property VolumeSize As Double (read/write)

Gets/sets volume size in bytes for split volumes to be created during compression. Can be used with 7z archives only. For other formats splits output archive in VolumeSize sized chunks which is not supported model by native decompressors.

Property FormatCount As Long (read-only)

Gets number of formats supported by 7z.dll which has been loaded on Init.

Property FormatInfo(FormatIdx As Long) As Variant (read-only)

Returns an array with information about compression format. Array indexes are: 0 - name, 1 - class ID, 2 - file extension(s), 3 - additional extensions (if any), 4 - bool if update supported, 5 - bool if keeps names, 6 - byte array with archive start signature, 7 - byte array with archive finish signature.

Property LastError As String (read-only)

Gets last error that occurred during last operation. Returns empty string if no error occurred.

Property PreserveDirectoryStructure As Boolean

Gets/sets whether to preserve directory structure of archive under TargetFolder during extraction.

Event Progress(FileIdx As Long, Current As Double, Total As Double, Cancel As Boolean)

Raised when new information about current operation progress is available and to give the user a chance to cancel operation. FileIdx is the index of the current file being extracted/compressed. This index can be used with FileInfo property. Current and Total parameters can be using to calculate percentage completed. Cancel can be set to abort current operation.

Event Error(Description As String, Source As String, Cancel As Boolean)

Raised when an unexpected condition occurs during current operation. Description contains User cancelled when Cancel gets set in Progress event. Description contains Data Error. Wrong password? if wrong password is supplied for extraction of encrypted archives. Can be raised when input/output files are inaccessible (permissions, network outages). Setting Cancel indicates whether to finish operation or abort it immediately.

Event NewVolume(FileName As String)

Raised when creating multi-volume archives to indicate new file names that are created during compression. Useful if volumes are to be deleted on error or user cancellation.

BeforeExtract(ByVal FileIdx As Long, FileName As String, SkipFile As Boolean, Cancel As Boolean)

Raised before extracting a file from archive. FileName can be used to change target output filename on the fly. SkipFile can be used to selectively extract files based on logic that cannot be implemented with Filter argument of Extract method. Cancel can be set to abort further extraction.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].