All Projects → rikyoz → Bit7z

rikyoz / Bit7z

Licence: gpl-2.0
A C++ static library offering a clean and simple interface to the 7-zip DLLs.

Programming Languages

cpp
1120 projects

Projects that are alternatives of or similar to Bit7z

Leanify
lightweight lossless file minifier/optimizer
Stars: ✭ 694 (+336.48%)
Mutual labels:  zip, tar, compression, gzip
Sharpcompress
SharpCompress is a fully managed C# library to deal with many compression types and formats.
Stars: ✭ 1,397 (+778.62%)
Mutual labels:  zip, tar, compression, gzip
ratarmount
Random Access Read-Only Tar Mount
Stars: ✭ 217 (+36.48%)
Mutual labels:  compression, gzip, zip, tar
Compress
Optimized Go Compression Packages
Stars: ✭ 2,478 (+1458.49%)
Mutual labels:  compression, gzip, zip
Libarchivejs
Archive library for browsers
Stars: ✭ 145 (-8.81%)
Mutual labels:  zip, tar, gzip
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 (+20.13%)
Mutual labels:  zip, compression, gzip
Zippy
Pure Nim implementation of deflate, zlib, gzip and zip.
Stars: ✭ 88 (-44.65%)
Mutual labels:  zip, compression, gzip
Turbobench
Compression Benchmark
Stars: ✭ 211 (+32.7%)
Mutual labels:  zip, compression, gzip
Unifiedarchive
UnifiedArchive - an archive manager with a unified way for different formats. Supports all basic (listing, reading, extracting and creation) and specific features (compression level, password-protection). Bundled with console program for working with archives.
Stars: ✭ 246 (+54.72%)
Mutual labels:  zip, tar, gzip
compress
compress and uncompress for Deno
Stars: ✭ 29 (-81.76%)
Mutual labels:  gzip, zip, tar
Swcompression
A Swift framework for working with compression, archives and containers.
Stars: ✭ 110 (-30.82%)
Mutual labels:  zip, tar, gzip
zipstream
A command line tool that allows you to easily share files and directories over the network
Stars: ✭ 49 (-69.18%)
Mutual labels:  gzip, zip, tar
Archiver
Easily create & extract archives, and compress & decompress files of various formats
Stars: ✭ 3,373 (+2021.38%)
Mutual labels:  zip, tar, gzip
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 (+420.13%)
Mutual labels:  zip, compression
Tinydeflate
A deflate/gzip decompressor that requires minimal amount of memory to work
Stars: ✭ 148 (-6.92%)
Mutual labels:  compression, gzip
Genozip
Compressor for genomic files (FASTQ, SAM/BAM, VCF, FASTA, GVF, 23andMe...), up to 5x better than gzip and faster too
Stars: ✭ 53 (-66.67%)
Mutual labels:  compression, gzip
Minizip Ng
Fork of the popular zip manipulation library found in the zlib distribution.
Stars: ✭ 750 (+371.7%)
Mutual labels:  zip, compression
Zipper
🗳A library to create, read and modify ZIP archive files, written in Swift.
Stars: ✭ 38 (-76.1%)
Mutual labels:  zip, compression
Zip
Efficient library for manipulating zip archives
Stars: ✭ 69 (-56.6%)
Mutual labels:  zip, compression
Denoflate
WebAssembly powered Deflate/Gzip/Zlib compression for Deno, written in Rust
Stars: ✭ 80 (-49.69%)
Mutual labels:  compression, gzip

bit7z

A C++ static library offering a clean and simple interface to the 7-zip DLLs

GitHub release MSVC 2012 - 2019 x86, x86_64 Docs Donations Build status License

Supported FeaturesGetting StartedDownloadRequirementsBuildingDonationsLicense

Introduction

bit7z is a C++ static library which allows to compress and extract many file archive formats, all through a clean, simple and entirely object-oriented interface to the dynamic libraries from the 7-zip project (https://www.7-zip.org/).
It supports compression and extraction to and from the filesystem or the memory, reading of archives metadata, updating existing archives, creation of multi-volume archives, operation progress callbacks and many other functionalities.

Supported Features

  • Compression using the following archive formats: 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM.
  • Extraction of the following archive formats: 7z, AR, ARJ, BZIP2, CAB, CHM, CPIO, CramFS, DEB, DMG, EXT, FAT, GPT, GZIP, HFS, HXS, IHEX, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, QCOW2, RAR, RAR5, RPM, SquashFS, TAR, UDF, UEFI, VDI, VHD, VMDK, WIM, XAR, XZ, Z and ZIP.
  • Reading metadata of archives and of their content (from v3.x).
  • Testing archives for errors (from v3.x).
  • Updating existing file archives (from v3.1.x).
  • Compression and extraction to and from memory (from v2.x — compression to memory is supported only for BZIP2, GZIP, XZ and TAR formats).
  • Compression and extraction to and from C++ standard streams (from v3.1.x).
  • Compression using a custom directory system in the output archives (from v3.x)
  • Selective extraction of only specified files/folders using wildcards (from v3.x) and regexes (from v3.1.x).
  • Creation of encrypted archives (strong AES-256 encryption — only for 7z and ZIP formats).
  • Archive header encryption (only for 7z format).
  • Choice of the compression level (from none to ultra, not all supported by every output archive format).
  • Choice of the compression method (from v3.1.x — see the wiki for the supported methods).
  • Choice of the compression dictionary size (from v3.1.x).
  • Automatic input archive format detection (from v3.1.x).
  • Solid archives (only for 7z).
  • Multi-volume archives (from v2.1.x).
  • Operation callbacks, through which it is possible to obtain real time information about the ongoing extraction or compression operation (from v2.1.x).

Please note that the presence or not of some of the above features depends on the particular .dll used along with bit7z.

For example, the 7z.dll should support all these features, while 7za.dll should support only the 7z file format and the 7zxa.dll can only extract 7z files. For more information about the 7-zip DLLs, please see this wiki page.

In the end, some other features (e.g. automatic format detection and selective extraction using regexes) are disabled by default and macros defines must be used during compilation to have them available (wiki).

Getting Started (Library Usage)

Below are a few examples that show how to use some of the main features of bit7z:

Extracting files from an archive

#include "bitextractor.hpp"

using namespace  bit7z;

try {
    Bit7zLibrary lib{ L"7za.dll" };
    BitExtractor extractor{ lib, BitFormat::SevenZip };

    extractor.extract( L"path/to/archive.7z", L"out/dir/" ); //extracting a simple archive

    extractor.extractMatching( L"path/to/arc.7z", L"file.pdf", L"out/dir/" ); //extracting a specific file

    //extracting the first file of an archive to a buffer
    std::vector< byte_t > buffer;
    extractor.extract( L"path/to/archive.7z", buffer );

    //extracting an encrypted archive
    extractor.setPassword( L"password" );
    extractor.extract( L"path/to/another/archive.7z", L"out/dir/" );
} catch ( const BitException& ex ) {
    //do something with ex.what()...
}

Compressing files into an archive

#include "bitcompressor.hpp"

using namespace bit7z;

try {
    Bit7zLibrary lib{ L"7z.dll" };
    BitCompressor compressor{ lib, BitFormat::Zip };

    std::vector< std::wstring > files = { L"path/to/file1.jpg", L"path/to/file2.pdf" };

    compressor.compress( files, L"output_archive.zip" ); //creating a simple zip archive

    //creating a zip archive with a custom directory structure
    std::map< std::wstring, std::wstring > files_map = { { L"path/to/file1.jpg", L"alias/path/file1.jpg" },
    { L"path/to/file2.pdf", L"alias/path/file2.pdf" } };
    compressor.compress( files_map, L"output_archive2.zip" );

    compressor.compressDirectory( L"dir/path/", L"dir_archive.zip" ); //compressing a directory

    //creating an encrypted zip archive of two files
    compressor.setPassword( L"password" );
    compressor.compressFiles( files, L"protected_archive.zip" );

    //updating an existing zip archive
    compressor.setUpdateMode( true );
    compressor.compressFiles( files, L"existing_archive.zip" );

    //compressing a single file into a buffer
    std::vector< byte_t > buffer;
    BitCompressor compressor2{ lib, BitFormat::BZip2 };
    compressor2.compressFile( files[0], buffer );
} catch ( const BitException& ex ) {
    //do something with ex.what()...
}

Reading archive metadata

#include "bitarchiveinfo.hpp"

using namespace bit7z;

try {
    Bit7zLibrary lib{ L"7za.dll" };
    BitArchiveInfo arc{ lib, L"archive.7z", BitFormat::SevenZip };

    //printing archive metadata
    wcout << L"Archive properties" << endl;
    wcout << L" Items count: "   << arc.itemsCount() << endl;
    wcout << L" Folders count: " << arc.foldersCount() << endl;
    wcout << L" Files count: "   << arc.filesCount() << endl;
    wcout << L" Size: "          << arc.size() << endl;
    wcout << L" Packed size: "   << arc.packSize() << endl;
    wcout << endl;

    //printing archive items metadata
    wcout << L"Archive items";
    auto arc_items = arc.items();
    for ( auto& item : arc_items ) {
        wcout << endl;
        wcout << L" Item index: "   << item.index() << endl;
        wcout << L"  Name: "        << item.name() << endl;
        wcout << L"  Extension: "   << item.extension() << endl;
        wcout << L"  Path: "        << item.path() << endl;
        wcout << L"  IsDir: "       << item.isDir() << endl;
        wcout << L"  Size: "        << item.size() << endl;
        wcout << L"  Packed size: " << item.packSize() << endl;
    }
} catch ( const BitException& ex ) {
    //do something with ex.what()...
}

A complete API reference is available in the wiki section.

Download

Each released package contains a precompiled version of the library (both in debug and release mode) and the public API headers that are needed to use it in your program; packages are available for both x86 and x64 architectures.

Obviously, you can also clone/download this repository and build the library by yourself (please, see the wiki).

Requirements

  • Target OS: Windows (both x86 and x64).
  • Compiler: MSVC 2012 or greater (MSVC 2010 supported until v2.x).
  • DLLs: 7-zip DLLs (v19.00 for the GitHub release packages).

The 7-zip dlls are not shipped with bit7z but they are available at 7-zip.org.

Note: in order to use this library you should link your program not only with bit7z but also with oleaut32 and user32 (e.g. -lbit7z -loleaut32 -luser32).

Note 2: even if compiled with the latest version of 7-zip, bit7z should work also with the dlls of previous versions, such as v16.04. However, it is strongly suggested to use dlls with the same version.

Note 3: the code has been tested with MSVC 2012, 2015, 2017 and 2019.

Building bit7z

A guide on how to build this library is available here.

Donations

If you have found this project useful, please consider supporting it with a small donation or buying me a coffee/beer, so that I can keep improving it! Thank you! :)

Beerpay Buy Me a Coffee at ko-fi.com Donations

License (GPL v2)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Copyright © 2014 - 2019 Riccardo Ostani (@rikyoz)

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].