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

Overview

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)

Comments
  • Add CMakeLists.txt and fix README.md

    Add CMakeLists.txt and fix README.md

    Enable build with cmake also fixups to appveyor.yml

    Description

    This change will allow anyone to generate project files for any project

    Motivation and Context

    Cmake is a much more flexible and crossplatform build tool It should be possible for users to use other complilers like mingw(Not tested) I am a user and also partly a maintainer of https://github.com/getnamo/7zip-cpp which offers features nearly similar to bit7z, but the projects developement has stalled.

    How Has This Been Tested?

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] My change requires a change to the documentation.
    • [ ] I have updated the documentation accordingly.

    Add ctest framework after a test suite is added using google tests

    :heavy_check_mark: enhancement 
    opened by kenkit 14
  • [Question] Extract files/folders matching complex pattern?

    [Question] Extract files/folders matching complex pattern?

    Before describing my issue please allow me to thank you for this great, well written, and simple to use library which I just discovered, and which you are so generously providing free of charge -- I really appreciate it.

    I would like to extract files from an archive using a complex pattern. From the documentation it seems that BitExtractor::extractMatching() method should be used, but its pattern support does not seem to be documented.

    I checked the code in BitExtractor.cpp and to me it seems that it supports filesystem wildcards such as ? and *. Sadly, that is not adequate for my use case (I am unpacking NVIDIA drivers), because I want to use regex to match multiple variants of paths inside an archive.

    I see that there is also a callback support (FileCallback) but to me it seems that it doesn't allow to cancel either the current file or the whole operation so that appears to be a dead-end too as far as I am concerned.

    There are at least two approaches to solving this issue:

    1. Provide a BitExtractor::extractMatchingRegex() method which accepts regex string instead of filesystem wildcard pattern.
    2. Provide a callback which is receiving current item path (not just name), and which allows skipping an item and/or ending the archive operation based on its return value.

    Personally, I would prefer the option 1 and I believe it would be simple and fast to implement.

    An example of my regex filter for extraction of NVIDIA drivers:

    std::wstring DriverExtractRegex = LR"(^(Display\.(Driver|Optimus)|HDAudio|MSVCRT|NGXCore|NVI2|PhysX|PPC).*$|^GFExperience\\(PrivacyPolicy\\PrivacyPolicy_[a-z]{2}\-[A-Z]{2,3}\.htm|EULA.html|FunctionalConsent_[a-z]{2}\-[A-Z]{2,3}\.txt)$|^(ListDevices|license|EULA)\.txt$|^setup\.(cfg|exe)$)";
    

    An example of archive for extracting (542.8 MB download): http://us.download.nvidia.com/Windows/431.60/431.60-desktop-win10-64bit-international-whql.exe

    I am looking forward to your thoughts on this issue.

    :heavy_check_mark: enhancement 
    opened by levicki 9
  • std::sort fails on BitArchiveInfo::items

    std::sort fails on BitArchiveInfo::items

    Bit7z V3.1.3 Visual Studio 2019

    Thought I'd sort the vector by filename:

    bool sortfunc(BitArchiveItem a, BitArchiveItem b) { return a.name() < b.name(); }
    ...
    BitArchiveInfo bai{ lib, path, BitFormat::Rar };
    auto arc_items = bai.items();
    std::sort(arc_items.begin(), arc_items.end(), sortfunc);
    

    but got three of these utterly confusing compile errors:

    1>E:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\algorithm(7247,25): error C2280: 'bit7z::BitArchiveItem &bit7z::BitArchiveItem::operator =(const bit7z::BitArchiveItem &)': attempting to reference a deleted function
    1>E:\proj\DarkThumbs2\DT_Bit7z\bit7z\include\bitarchiveitem.hpp(106): message : compiler has generated 'bit7z::BitArchiveItem::operator =' here
    1>E:\proj\DarkThumbs2\DT_Bit7z\bit7z\include\bitarchiveitem.hpp(106,5): message : 'bit7z::BitArchiveItem &bit7z::BitArchiveItem::operator =(const bit7z::BitArchiveItem &)': function was implicitly deleted because 'bit7z::BitArchiveItem' has a data member 'bit7z::BitArchiveItem::mItemIndex' of const-qualified non-class type
    1>E:\proj\DarkThumbs2\DT_Bit7z\bit7z\include\bitarchiveitem.hpp(97): message : see declaration of 'bit7z::BitArchiveItem::mItemIndex'
    1>E:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\algorithm(7369): message : see reference to function template instantiation '_BidIt *std::_Insertion_sort_unchecked<_RanIt,bool(__cdecl *)(bit7z::BitArchiveItem,bit7z::BitArchiveItem)>(const _BidIt,const _BidIt,_Pr)' being compiled
    1>        with
    1>        [
    1>            _BidIt=bit7z::BitArchiveItem *,
    1>            _RanIt=bit7z::BitArchiveItem *,
    1>            _Pr=bool (__cdecl *)(bit7z::BitArchiveItem,bit7z::BitArchiveItem)
    1>        ]
    1>E:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\algorithm(7399): message : see reference to function template instantiation 'void std::_Sort_unchecked<bit7z::BitArchiveItem*,bool(__cdecl *)(bit7z::BitArchiveItem,bit7z::BitArchiveItem)>(_RanIt,_RanIt,__int64,_Pr)' being compiled
    1>        with
    1>        [
    1>            _RanIt=bit7z::BitArchiveItem *,
    1>            _Pr=bool (__cdecl *)(bit7z::BitArchiveItem,bit7z::BitArchiveItem)
    1>        ]
    1>E:\proj\DarkThumbs2\DT_Bit7z\rar.cpp(31): message : see reference to function template instantiation 'void std::sort<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,bool(__cdecl *)(bit7z::BitArchiveItem,bit7z::BitArchiveItem)>(const _RanIt,const _RanIt,_Pr)' being compiled
    1>        with
    1>        [
    1>            _Ty=bit7z::BitArchiveItem,
    1>            _RanIt=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<bit7z::BitArchiveItem>>>,
    1>            _Pr=bool (__cdecl *)(bit7z::BitArchiveItem,bit7z::BitArchiveItem)
    1>        ]
    

    I get the same result even if I create a copy of the items() vector.

    Any hints? Thanks!

    🐞 bug 
    opened by fire-eggs 7
  • Crash at compressOut

    Crash at compressOut

    Describe the bug it crash just sometimes, but don't know why.

    crash compressOut source paths: F:/01-绿色包备份/压缩包/DIYHomeV3.6.0测试/DIYHomeV3.17.0.03测试版本/Data/5/Scheme/jd004/4223E0B5-7B5E-423e-8C61-8148EAB96E43/X1000042001072/00/X1000042001072-16257152697900836.jx F:/01-绿色包备份/压缩包/DIYHomeV3.6.0测试/DIYHomeV3.17.0.03测试版本/Data/5/Scheme/jd004/4223E0B5-7B5E-423e-8C61-8148EAB96E43/X1000042001072/00/X1000042001072-16257152697900836.jpg F:/01-绿色包备份/压缩包/DIYHomeV3.6.0测试/DIYHomeV3.17.0.03测试版本/Data/5/Scheme/jd004/4223E0B5-7B5E-423e-8C61-8148EAB96E43/X1000042001072/00/X1000042001072-16257152697900836_H.json F:/01-绿色包备份/压缩包/DIYHomeV3.6.0测试/DIYHomeV3.17.0.03测试版本/Data/5/Scheme/jd004/4223E0B5-7B5E-423e-8C61-8148EAB96E43/X1000042001072/00/X1000042001072-16257152697900836_AttachH.json target path: F:/01-绿色包备份/压缩包/DIYHomeV3.6.0测试/DIYHomeV3.17.0.03测试版本/data/5/order/12924/47bb14b0d0274976ad87b7c08fabf3b4/4223E0B5-7B5E-423e-8C61-8148EAB96E43/X1000042001072-16257152697900836.zip

    Expected behavior A clear and concise description of what you expected to happen.

    Environment details (put an x in all the boxes that apply):

    • bit7z version:

      • [ ] v2.0
      • [ ] v2.1
      • [x ] v3.0
    • 7-zip version:

      • [ ] v16.02
      • [ ] v16.03
      • [ ] v16.04
      • [ ] v18.01
      • [ ] v18.03
      • [ ] v18.05
      • [x ] v21.02
    • MSVC version:

      • [ ] 2012
      • [x ] 2013
      • [ ] 2015
      • [ ] 2017
    • Windows version:

      • [ ] Windows Vista
      • [ ] Windows 8
      • [ ] Windows 8.1
      • [ x] Windows 10
    • Architecture:

      • [ x] x86
      • [ ] x86_64

    Additional context here is the call stack: vrfcore.dll!_VerifierStopMessageEx() Unknown vrfcore.dll!VfCoreRedirectedStopMessage(unsigned long,char *,unsigned long,char *,unsigned long,char *,unsigned long,char *,unsigned long,char *) Unknown vrfcore.dll!VfCoreRtlFreeHeap(void *,unsigned long,void *) Unknown oleaut32.dll!APP_DATA::FreeCachedMem(void *,unsigned long) Unknown oleaut32.dll!SysFreeStringImpl(unsigned short *) Unknown [email protected]() Unknown [email protected]() Unknown 7z_21.dll!564e48db() Unknown 7z_21.dll![Frames below may be incorrect and/or missing, no symbols loaded for 7z_21.dll] Unknown

    App.dll!compressOut(IOutArchive * out_arc, ISequentialOutStream * out_stream, bit7z::UpdateCallback * update_callback) Line 42 C++ App.dll!bit7z::BitArchiveCreator::compressToFile(const std::wstring & out_file, bit7z::UpdateCallback * update_callback) Line 267 C++ App.dll!bit7z::BitCompressor::compressOut(const std::vector<bit7z::filesystem::FSItem,std::allocatorbit7z::filesystem::FSItem> & in_items, const std::wstring & out_file) Line 119 C++ App.dll!bit7z::BitCompressor::compress(const std::vector<std::wstring,std::allocatorstd::wstring> & in_paths, const std::wstring & out_file) Line 42 C++ App.dll!bit7zCompressFiles(const std::vector<std::string,std::allocatorstd::string> & vecFiles, const std::string & strTargetPath) Line 170 C++

    🐞 bug :information_source: more-information-needed 
    opened by nolanjian 7
  • Extract specific file to buffer

    Extract specific file to buffer

    Is your feature request related to a problem? Please describe. No

    Describe the solution you'd like I can see that we can extract specific files by matching paths. However I'd like to extract a specific file to buffer. I'm not sure how long it will take to implement this since my app needs this feature to extract webpages into a buffer.

    Additional context (optional) Something like this

    extractor.extract( L"path/to/another/file.txt", buffer );
    
    :heavy_check_mark: enhancement 
    opened by kenkit 7
  • [Bug]: Why can't compress an empty directory?

    [Bug]: Why can't compress an empty directory?

    bit7z version

    4.0.x beta

    7-zip version

    v21.07

    7-zip DLL used

    7z.dll

    MSVC version

    2019

    Architecture

    x86_64

    Which version of Windows are you using?

    Windows 10

    Bug description

    Why can't compress an empty directory?

    Steps to reproduce

    No response

    Expected behavior

    No response

    Relevant compilation output

    No response

    Code of Conduct

    🐞 bug 
    opened by kak13amaplus 5
  • [Feature Request]: how to uncompress Multi-volume archives file

    [Feature Request]: how to uncompress Multi-volume archives file

    Feature description

    any example ?

    Additional context

    No response

    Code of Conduct

    :grey_question: help 
    opened by anywhereyang 5
  • [Bug]: memory leaks can't delete or even destructor

    [Bug]: memory leaks can't delete or even destructor

    bit7z version

    3.1.x

    7-zip version

    v19.00

    7-zip DLL used

    7z.dll

    MSVC version

    2022

    Architecture

    x86_64, x86

    Which version of Windows are you using?

    Windows 10

    Bug description

    so basically I allocates memory by using new but i couldn't delete it or destructor it it's gave me error of

    Exception thrown: read access violation.
    this->mInArchive-> was 0x5B8A8D00.
    

    and show me this code

    BitInputArchive::~BitInputArchive() {
        if ( mInArchive ) {
            mInArchive->Release();
        }
    }
    

    error comes from mInArchive->Release(); i am using bit7z for reading and extracting archive files and this error only come when i am reading archives metadata(extracting is fine even it's same code just other functions to use)

    here full code of reading archive metadata:

    #pragma once
    
    #include "bitexception.hpp"
    #include "bitarchiveinfo.hpp"
    #include <iostream>
    #include <string>
    #include <windows.h>
    #include <stdexcept> 
    #include "getArchType.h"
    #include "hash.h"
    #include <shellapi.h>
    //#include "crc.h"
    //#include <filesystem>
    //#include <iomanip>
    
    
    
    using namespace  bit7z;
    
    
    constexpr auto USER_INPUT = 255;
    
    
    int archiveInfo(std::wstring dir) {
        try {
            /* 
            *
            * check system architecture
            * if x86 == load 7z.dll(x86)
            * if x64 == load 7z.dll(x64)
            * On x64 platforms sizeof(void*) returns 8. 
            * On x32 platforms sizeof(void*) returns 4.
            * 
            * */
            if (dir.size() > USER_INPUT)
                throw std::invalid_argument("argument too large.");
    
            BOOL windowsIs32Bit;
            BOOL isWOW64;
            BOOL processIs32Bit;
    
            if (!getBits(windowsIs32Bit, isWOW64, processIs32Bit)) {
                return -1;
            }
            Bit7zLibrary* lib = nullptr;
    
            //// Bit7zLibrary lib2;
            //// lib2 = new Bit7zLibrary(L"C:\\path-to-lib\\7z.dll");
    
    
            if (!windowsIs32Bit) {
                lib = new Bit7zLibrary(L"C:\\path-to-lib\\7z.dll");
            }
            else if (windowsIs32Bit) {
                lib = new Bit7zLibrary(L"C:\\path-to-lib\\7z.dll");
            }
            else {
                throw std::invalid_argument("arch type is not supported.");
            }
            //lib->setLargePageMode();
    
            BitArchiveInfo arc{ *lib, dir, BitFormat::Auto };
            
            // printing archive metadata
            // std::wcout << L"Archive properties" << std::endl;
            // Archive properties
            std::wstring tmp;
            std::wstring hash_args;
            std::wcout << arc.itemsCount() << std::endl; //  Items count: 
            std::wcout << arc.foldersCount() << std::endl;// Folders count:
            std::wcout << arc.filesCount() << std::endl;//   Files count: 
            std::wcout << arc.size() << std::endl;//         Size:
            std::wcout << arc.packSize() << std::endl;//     Packed size:
    
            std::wcout << std::endl;
    
       
            // Archive items
    
            auto arc_items = arc.items();
            long int filesize = 0;
            for (auto& item : arc_items) {
                //std::wcout << std::endl;
                std::wcout << item.index() << std::endl; //     Item index: 
                std::wcout << item.name() << std::endl; //      Name:
                std::wcout << item.extension() << std::endl; // Extension: 
                std::wcout << item.path() << std::endl; //      Path: 
                std::wcout << item.isDir() << std::endl; //     IsDir:
                std::wcout << item.size() << std::endl; //      Size: 
                std::wcout << item.packSize() << std::endl; //  Packed size:
                
                
                if (item.extension() != L""){
                    // MD5 C++ WINAPI
                    tmp = item.path();
                    std::wcout << tmp << std::endl;
                    std::cout << getHash(tmp) << std::endl;
    
                    // MD5 CMD
                    //hash_args = L"certutil -hashfile " + item.path() + L" " + L"md5";
                    //_wsystem(hash_args.c_str());
                    // 
                    // CRC 32
                    //data = (char*)malloc(item.size());
                    //crc = CRC::Calculate(data, item.size(), CRC::CRC_32());
                    //std::cout << std::hex << std::setw(8) << std::setfill('0') << crc << std::endl;
    
                }
                std::cout << "\n\n\n\n";
            }
            delete lib; // delete allocate we created with *new* 
    
            //lib ->~Bit7zLibrary();
        }
    
        catch (const BitException& ex) { //        for dll not loaded
            std::cerr << ex.what() << std::endl;
            return -1;
        }
        catch (const std::invalid_argument& e){ // for limit the string length
            std::cerr << e.what() << std::endl;
            return -1;
        }
        catch (...) {
            std::cerr << "Found an unknown exception." << std::endl;
            return -1;
        }
      
        return 0;
    }
    

    delete lib; or lib ->~Bit7zLibrary(); are giving me Exception thrown: read access violation. how to fix that?

    is there anyway to load dll one time after checking system architecture ?

    Steps to reproduce

    No response

    Expected behavior

    No response

    Relevant compilation output

    No response

    Code of Conduct

    :grey_question: help :green_book: not-bug 
    opened by EbadiDev 5
  • [Bug]: mErrorCode=CLASS_E_CLASSNOTAVAILABLE ClassFactory cannot supply requested class

    [Bug]: mErrorCode=CLASS_E_CLASSNOTAVAILABLE ClassFactory cannot supply requested class

    bit7z version

    3.1.x

    7-zip version

    v21.07

    7-zip DLL used

    7za.dll

    MSVC version

    2017

    Architecture

    x86_64

    Which version of Windows are you using?

    Windows 10

    Bug description

    unable extract. error: {mErrorCode=CLASS_E_CLASSNOTAVAILABLE ClassFactory cannot supply requested class }

    void extractVolumeExample()
    {
    	try
    	{
    		Bit7zLibrary lib{ L"C:/Users/admin/source/repos/bit7z-demo/libs/bit7z/lib/7za.dll" };
    		BitExtractor extractor{ lib, BitFormat::Split };
    		extractor.extract(L"D:/test/volumes/out/.001", L"D:/test/volumes/out/_");
    		std::cout << "Done";
    	}
    	catch (const BitException& ex) {
    		std::cout << "error";
    		//do something with ex.what()...
    	}
    }
    

    Steps to reproduce

    No response

    Expected behavior

    No response

    Relevant compilation output

    No response

    Code of Conduct

    :green_book: not-bug 
    opened by jf3096 5
  • Correct form of function used

    Correct form of function used

    Description

    Motivation and Context

    How Has This Been Tested?

    Types of changes

    • [x] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] My change requires a change to the documentation.
    • [x] I have updated the documentation accordingly.
    :information_source: more-information-needed 
    opened by CruiseYoung 5
  • Custom read/write handlers from user

    Custom read/write handlers from user

    Describe the solution you'd like Should allow user to set custom read/write handlers e.g when user wants to set http archive reading.

    Additional context (optional) This will make the library much more flexible and powerfull. E.g user can set ftp/http archive url and the library should be able to list/extract without downloading the full archive via custom handlers.

    :heavy_check_mark: enhancement 
    opened by kenkit 5
  • [Feature Request]: Consider adding compile options to output position independent code by default

    [Feature Request]: Consider adding compile options to output position independent code by default

    Feature description

    First of all thank you all for providing such a nice library, it is a joy to use!

    I just ran into a little trouble when creating a shared library on linux that linked against libbit7z64.a, which I created following the default build instruction in the readme. The errors looked similar to the ones described in this SO Question. TIL about position independent code.

    Adding set(CMAKE_POSITION_INDEPENDENT_CODE ON) to the top level CMakeLists.txt solved the issue for me.

    It seems like this would be relevant for a lot of other users, hence this issue. I wasn't sure if a pull request would be more suitable for this minor suggestion. Just let me know if you would prefer that.

    Additional context

    Interestingly, I did not experience this issue on windows where I integated your library first without problems.

    Code of Conduct

    :heavy_check_mark: enhancement 
    opened by janreitz 1
  • [Feature Request]: Is there any plan to set version 4.0 to support C++11?

    [Feature Request]: Is there any plan to set version 4.0 to support C++11?

    Feature description

    Cause C++11 is more widely used C_standard, many projects are based on it . Thank you and expect for your reply.

    Additional context

    No response

    Code of Conduct

    opened by musuoliniao 1
  • [Feature Request]: provide a way to set options or parameters

    [Feature Request]: provide a way to set options or parameters

    Feature description

    I need to avoid storing the NTFS extra field (where the last accessed, modified, and created times are stored). I saw that one way to do it in 7zip was to use the -mtc=off parameter. I did not find any way to do it when creating a .zip file using this library. Is there any way? Thanks

    Additional context

    No response

    Code of Conduct

    :heavy_check_mark: enhancement 
    opened by pabloglombovsky 3
  • BitExtractor to MapViewFile

    BitExtractor to MapViewFile

    Feature description

    When operating large files, use memory mapped files. I want to extract them into memory mapped files.

    Additional context

    void extract( const wstring& in_file, vector< byte_t >& out_buffer, unsigned int index = 0 ) const;

    this must is vector<byte_t> type,i want is any type

    Code of Conduct

    :heavy_check_mark: enhancement 
    opened by BiaoGe2399 0
  • Would you like consider to port bit7z to Vcpkg?

    Would you like consider to port bit7z to Vcpkg?

    Feature description

    port bit7z to Vcpkg?

    Additional context

    NA

    Code of Conduct

    :heavy_check_mark: enhancement 
    opened by jsnhsu 1
  • [Feature Request]: bitCompressor with update = false should recreate the archive

    [Feature Request]: bitCompressor with update = false should recreate the archive

    Feature description

    The behavior right now is that if compressor.setUpdateMode(false); and the archive already exists, an exception is thrown. It could be easy to fix by checking the existence of the file and deleting the archive before opening the output stream. The same (and most important) thing should be done if creating volumes, because every existing part raises an exception now.

    Regards

    Additional context

    No response

    Code of Conduct

    :heavy_check_mark: enhancement 
    opened by cobian-test 1
Releases(v3.2.0)
Owner
Riccardo
Software Developer 💻 ~ «Time is an illusion. Lunchtime doubly so.» ― Douglas Adams
Riccardo
Fork of the popular zip manipulation library found in the zlib distribution.

minizip-ng 3.0.1 minizip-ng is a zip manipulation library written in C that is supported on Windows, macOS, and Linux. Developed and maintained by Nat

zlib-ng 971 Jan 4, 2023
An embedded-friendly library for decompressing files from zip archives

An 'embedded-friendly' (aka Arduino) library to extract and decompress files from ZIP archives

Larry Bank 33 Dec 30, 2022
Runtime Archiver plugin for Unreal Engine. Cross-platform archiving and unarchiving directories and files. Currently supports ZIP format.

Runtime Archiver Archiving and dearchiving directories and files Explore the docs » Marketplace . Releases . Support Chat Features Fast speed Easy arc

Georgy Treshchev 26 Dec 15, 2022
gzip (GNU zip) is a compression utility designed to be a replacement for 'compress'

gzip (GNU zip) is a compression utility designed to be a replacement for 'compress'

ACM at UCLA 8 Nov 6, 2022
Simple data packing library (written in C99)

Features Compressed file pack creation Runtime file pack reading Supported operating systems Ubuntu MacOS Windows Build requirements C99 compiler CMak

Nikita Fediuchin 3 Feb 25, 2022
A simple C library implementing the compression algorithm for isosceles triangles.

orvaenting Summary A simple C library implementing the compression algorithm for isosceles triangles. License This project's license is GPL 2 (as of J

Kevin Matthes 0 Apr 1, 2022
Multi-format archive and compression library

Welcome to libarchive! The libarchive project develops a portable, efficient C library that can read and write streaming archives in a variety of form

null 1.9k Jan 8, 2023
LZFSE compression library and command line tool

LZFSE This is a reference C implementation of the LZFSE compressor introduced in the Compression library with OS X 10.11 and iOS 9. LZFSE is a Lempel-

null 1.7k Jan 4, 2023
Advanced DXTc texture compression and transcoding library

crunch/crnlib v1.04 - Advanced DXTn texture compression library Public Domain - Please see license.txt. Portions of this software make use of public d

null 775 Dec 26, 2022
miniz: Single C source file zlib-replacement library, originally from code.google.com/p/miniz

Miniz Miniz is a lossless, high performance data compression library in a single source file that implements the zlib (RFC 1950) and Deflate (RFC 1951

Rich Geldreich 1.6k Jan 5, 2023
Small strings compression library

SMAZ - compression for very small strings ----------------------------------------- Smaz is a simple compression library suitable for compressing ver

Salvatore Sanfilippo 1k Dec 28, 2022
A massively spiffy yet delicately unobtrusive compression library.

ZLIB DATA COMPRESSION LIBRARY zlib 1.2.11 is a general purpose data compression library. All the code is thread safe. The data format used by the z

Mark Adler 4.1k Dec 30, 2022
PhysFS++ is a C++ wrapper for the PhysicsFS library.

PhysFS++ PhysFS++ is a C++ wrapper for the excellent PhysicsFS library by Ryan C. Gordon and others. It is licensed under the zlib license - same as P

Kevin Howell 80 Oct 25, 2022
Gzip header-only C++ library

Gzip C++ lib for gzip compression and decompression. Extracted from mapnik-vector-tile for light-weight modularity. Usage // Include the specific gzip

Mapbox 243 Jan 1, 2023
New generation entropy codecs : Finite State Entropy and Huff0

New Generation Entropy coders This library proposes two high speed entropy coders : Huff0, a Huffman codec designed for modern CPU, featuring OoO (Out

Yann Collet 1.1k Dec 29, 2022
Fuzzing harnesses, corpora, scripts, and target-specific notes for fuzzing IrfanView

FuzzIrfanView Here is the accompany repository for my blog post, Fuzzing IrfanView with WinAFL. It contains the following: The scripts used to downloa

Moshe Kaplan 15 Oct 29, 2022
Slow5tools is a toolkit for converting (FAST5 <-> SLOW5), compressing, viewing, indexing and manipulating data in SLOW5 format.

slow5tools Slow5tools is a simple toolkit for converting (FAST5 <-> SLOW5), compressing, viewing, indexing and manipulating data in SLOW5 format. Abou

Hasindu Gamaarachchi 57 Dec 2, 2022
PNGFuse is a cross-platform application that allows you to embed and extract full zlib-compressed files within PNG metadata.

PNGFuse PNGFuse is a portable, lightweight, and cross-platform application written in C++ that allows you to embed and extract full zlib-compressed fi

Eta 3 Dec 29, 2021
Experimental data compressor for 8-bit computers and low-end platforms

ZX5 (experimental) ZX5 is an experimental data compressor derived from ZX0, similarly targeted for low-end platforms, including 8-bit computers like t

Einar Saukas 9 Apr 14, 2022