Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: build

on:
push:
tags:
- 'v*'
branches:
- master
pull_request:
branches:
- master

jobs:
build-all:
runs-on: ${{ matrix.config.os }}
name: 'Build on ${{ matrix.config.os }} (${{ matrix.config.cxx }}, ${{ matrix.type }}, SHARED=${{ matrix.build_shared }})'
strategy:
fail-fast: false
matrix:
config:
- { os: "ubuntu-latest", cxx: "g++" }
- { os: "ubuntu-latest", cxx: "clang++" }
- { os: "windows-latest", cxx: "cl" }
type:
- "Debug"
- "Release"
build_shared:
- "ON"
- "OFF"
exclude:
- config: { os: "windows-latest", cxx: "cl" }
build_shared: "ON"
steps:
- name: "Checkout"
uses: actions/checkout@v7
with:
submodules: 'true'

- name: "Prepare Windows environment"
uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.config.os == 'windows-latest' }}
with:
arch: win64

- name: "Install dependencies"
if: ${{ matrix.config.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install -y 7zip

- name: "Build with ${{ matrix.config.cxx }}"
env:
CXX: ${{ matrix.config.cxx }}
run: |
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DLIB7ZIP_BUILD_SHARED_LIB=${{ matrix.build_shared }}
cmake --build build -j2
77 changes: 26 additions & 51 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,70 +1,45 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.24)

CMAKE_POLICY(
SET CMP0048 NEW
PROJECT(lib7zip
VERSION 4.0.0
LANGUAGES CXX
)

PROJECT (lib7zip
VERSION 4.0.0
)
SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

INCLUDE(ExternalProject)
INCLUDE(GNUInstallDirs)

IF(APPLE)
IF (APPLE)
SET(CMAKE_MACOSX_RPATH 1)
SET(CMAKE_PREFIX_PATH /usr/local)
ENDIF()
ENDIF ()

IF(NOT CMAKE_BUILD_TYPE)
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "DEBUG")
#SET(CMAKE_BUILD_TYPE "RELEASE")
#SET(CMAKE_BUILD_TYPE "RELWITHDEBINFO")
#SET(CMAKE_BUILD_TYPE "MINSIZEREL")
ENDIF()

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")

OPTION(BUILD_SHARED_LIB "build shared library" OFF)
ENDIF ()

# Use submodule 7zip source by default, allow override with SEVENZIP_SOURCE_DIR
IF(NOT DEFINED SEVENZIP_SOURCE_DIR)
SET(SEVENZIP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/7zip")
ENDIF()
SET(SEVENZIP_SOURCE_DIR "${PROJECT_SOURCE_DIR}/third_party/7zip" CACHE STRING "Location of 7zip sources")
OPTION(LIB7ZIP_BUILD_SHARED_LIB "Build shared library (only for *nix)" OFF)
OPTION(LIB7ZIP_ENABLE_TESTING "Enable testing" ${PROJECT_IS_TOP_LEVEL})
OPTION(LIB7ZIP_WARNING_AS_ERROR "Threat all compiler warnings as errors" ${PROJECT_IS_TOP_LEVEL})

IF (NOT IS_DIRECTORY ${SEVENZIP_SOURCE_DIR})
MESSAGE(FATAL_ERROR "7zip source not found at ${SEVENZIP_SOURCE_DIR}. Please ensure git submodule is initialized: git submodule update --init --recursive")
ENDIF()

SET(SEVENZIP_INCLUDE_PATH "${SEVENZIP_SOURCE_DIR}"
"${SEVENZIP_SOURCE_DIR}/CPP"
"${SEVENZIP_SOURCE_DIR}/CPP/Common"
"${SEVENZIP_SOURCE_DIR}/CPP/Windows"
"${SEVENZIP_SOURCE_DIR}/C"
"${CMAKE_CURRENT_SOURCE_DIR}/includes"
)
ENDIF ()


if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(warnings -Wall -Wextra -Werror -Wno-unused-parameter)
set(cxx_warnings -Wno-class-memaccess)
set(no_undefined -Wl,--no-undefined)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(warnings -Wall -Wextra -Werror -Wno-inconsistent-missing-override -Wno-unused-parameter)
set(cxx_warnings "")
set(no_undefined -Wl,-undefined,error)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(warnings /W4 /WX /EHsc)
set(no_undefined "")
set(cxx_warnings "")
endif()

SET(CXX_STANDARD_REQUIRED OFF)
SET(CXX_EXTENSION NO)

if (NOT CONFIGURED_ONCE)
ADD_COMPILE_OPTIONS(-fPIC -std=c++14 ${warnings} ${cxx_warnings})
ADD_LINK_OPTIONS(${no_undefined})
endif()
IF (LIB7ZIP_WARNING_AS_ERROR)
SET(CMAKE_COMPILE_WARNING_AS_ERROR ON)
ENDIF ()

ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(test)
IF (LIB7ZIP_ENABLE_TESTING)
ADD_SUBDIRECTORY(test)
ENDIF ()

# Install
INSTALL(FILES README.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ lib7zip is a C++ wrapper library for accessing 7-Zip archives programmatically.
# Method 1: CMake with Submodule (Recommended)
git submodule update --init --recursive
mkdir build && cd build
cmake .. -DBUILD_SHARED_LIB=OFF
cmake ..
make -j4

# Method 2: Direct compilation (Advanced users)
Expand All @@ -29,7 +29,7 @@ ar rcs lib7zip.a *.o

- **7-Zip 25.0 Source**: Included as git submodule at `third_party/7zip/`
- **C++ Compiler**: GCC 8+ or Clang 10+ with C++14 support
- **Build Tools**: CMake 3.5+ for CMake method, git for submodule management
- **Build Tools**: CMake 3.24+ for CMake method, git for submodule management
- **System Libraries**: pthread, dl (standard on most Linux systems)

## 🔧 Build Instructions
Expand All @@ -46,7 +46,7 @@ git submodule update --init --recursive
mkdir -p build && cd build

# Configure (7-Zip source auto-detected from submodule)
cmake .. -DBUILD_SHARED_LIB=OFF
cmake ..

# Build library
make -j4
Expand Down Expand Up @@ -126,14 +126,13 @@ export LD_LIBRARY_PATH=./build/src:$LD_LIBRARY_PATH

## 🎯 Project Status

| Component | Status | Notes |
|-----------|--------|-------|
| **Core Library** | ✅ **Ready** | Fully functional with 7-Zip 25.0 |
| **Static Library** | ✅ **Ready** | Successfully builds with CMake |
| **Shared Library** | ✅ **Ready** | Optional, enable with -DBUILD_SHARED_LIB=ON |
| **COM Interfaces** | ✅ **Ready** | All interfaces updated for 7-Zip 25.0 |
| **API Compatibility** | ✅ **Ready** | Backward compatible API maintained |
| **Test Programs** | ⚠️ **Partial** | Core library works, tests need minor updates |
| Component | Status | Notes |
|---------------------------|----------------|----------------------------------------------|
| **Core Library** | ✅ **Ready** | Fully functional with 7-Zip 25.0 |
| **Shared/Static Library** | ⚠️ **Partial** | Windows supports only static linking |
| **COM Interfaces** | ✅ **Ready** | All interfaces updated for 7-Zip 25.0 |
| **API Compatibility** | ✅ **Ready** | Backward compatible API maintained |
| **Test Programs** | ⚠️ **Partial** | Core library works, tests need minor updates |

## 🔍 Verification

Expand Down
21 changes: 10 additions & 11 deletions src/7ZipArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "CPP/Common/MyCom.h"
#include "CPP/7zip/ICoder.h"
#include "CPP/7zip/IPassword.h"
#include "CPP/7zip/Common/FileStreams.h"

#include "HelperFuncs.h"

Expand All @@ -35,21 +34,21 @@ class C7ZipOutStreamWrap:
public:
Z7_COM_UNKNOWN_IMP_1(IOutStream)

STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) throw()
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) throw() override
{
return m_pOutStream->Seek(offset, seekOrigin, newPosition);
}

#if MY_VER_MAJOR > 9 || (MY_VER_MAJOR == 9 && MY_VER_MINOR>=20)
STDMETHOD(SetSize)(UInt64 newSize) throw()
STDMETHOD(SetSize)(UInt64 newSize) throw() override
#else
STDMETHOD(SetSize)(Int64 newSize) throw()
STDMETHOD(SetSize)(Int64 newSize) throw() override
#endif
{
return m_pOutStream->SetSize(newSize);
}

STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) throw()
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) throw() override
{
return m_pOutStream->Write(data, size, processedSize);
}
Expand All @@ -68,16 +67,16 @@ class CArchiveExtractCallback:
Z7_COM_UNKNOWN_IMP_1(ICryptoGetTextPassword)

// IProgress
STDMETHOD(SetTotal)(UInt64 size) throw();
STDMETHOD(SetCompleted)(const UInt64 *completeValue) throw();
STDMETHOD(SetTotal)(UInt64 size) throw() override;
STDMETHOD(SetCompleted)(const UInt64 *completeValue) throw() override;

// IArchiveExtractCallback
STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode) throw();
STDMETHOD(PrepareOperation)(Int32 askExtractMode) throw();
STDMETHOD(SetOperationResult)(Int32 resultEOperationResult) throw();
STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode) throw() override;
STDMETHOD(PrepareOperation)(Int32 askExtractMode) throw() override;
STDMETHOD(SetOperationResult)(Int32 resultEOperationResult) throw() override;

// ICryptoGetTextPassword
STDMETHOD(CryptoGetTextPassword)(BSTR *aPassword) throw();
STDMETHOD(CryptoGetTextPassword)(BSTR *aPassword) throw() override;

virtual bool SetFileSymLinkAttrib() {
return false;
Expand Down
1 change: 0 additions & 1 deletion src/7ZipArchiveItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "CPP/Common/MyCom.h"
#include "CPP/7zip/ICoder.h"
#include "CPP/7zip/IPassword.h"
#include "CPP/7zip/Common/FileStreams.h"

#include "lib7zip.h"
#include "HelperFuncs.h"
Expand Down
12 changes: 6 additions & 6 deletions src/7ZipArchiveOpenCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ public IArchiveOpenCallback,
);

// IArchiveOpenCallback
STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes) throw();
STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes) throw();
STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes) throw() override;
STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes) throw() override;

// IArchiveOpenVolumeCallback
STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value) throw();
STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream) throw();
STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value) throw() override;
STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream) throw() override;

// ICryptoGetTextPassword
STDMETHOD(CryptoGetTextPassword)(BSTR *password) throw();
STDMETHOD(CryptoGetTextPassword)(BSTR *password) throw() override;

STDMETHOD(SetSubArchiveName(const wchar_t *name)) throw() {
STDMETHOD(SetSubArchiveName(const wchar_t *name)) throw() override {
_subArchiveMode = true;
_subArchiveName = name;
TotalSize = 0;
Expand Down
10 changes: 5 additions & 5 deletions src/7ZipCompressCodecsInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class C7ZipCompressCodecsInfo : public ICompressCodecsInfo,
Z7_COM_UNKNOWN_IMP_1(ICompressCodecsInfo)

#if MY_VER_MAJOR >= 15
STDMETHOD(GetNumMethods)(UInt32 *numMethods) throw();
STDMETHOD(GetNumMethods)(UInt32 *numMethods) throw() override;
#else
STDMETHOD(GetNumberOfMethods)(UInt32 *numMethods) throw();
STDMETHOD(GetNumberOfMethods)(UInt32 *numMethods) throw() override;
#endif
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) throw();
STDMETHOD(CreateDecoder)(UInt32 index, const GUID *interfaceID, void **coder) throw();
STDMETHOD(CreateEncoder)(UInt32 index, const GUID *interfaceID, void **coder) throw();
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) throw() override;
STDMETHOD(CreateDecoder)(UInt32 index, const GUID *interfaceID, void **coder) throw() override;
STDMETHOD(CreateEncoder)(UInt32 index, const GUID *interfaceID, void **coder) throw() override;

void InitData();
private:
Expand Down
6 changes: 3 additions & 3 deletions src/7ZipInStreamWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class C7ZipInStreamWrapper:
public:
Z7_COM_UNKNOWN_IMP_2(IInStream, IStreamGetSize)

STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) throw();
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) throw();
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) throw() override;
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) throw() override;

STDMETHOD(GetSize)(UInt64 *size) throw();
STDMETHOD(GetSize)(UInt64 *size) throw() override;

private:
C7ZipInStream * m_pInStream;
Expand Down
Loading