Skip to content

Commit

Permalink
feat: use vanilla 7zip instead of p7zip
Browse files Browse the repository at this point in the history
Arch linux switched to use 7zip instead of p7zip. This breaks the
fuse3-p7zip functionality.

The vanilla 7zip is portable now and can be used on linux (even though it lacks
some of codecs like brotli and zstd)
  • Loading branch information
andrew-grechkin committed Dec 27, 2024
1 parent 9cb0a3c commit 69088cd
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 59 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Install dependencies
run: sudo apt-get install -y build-essential cmake libfuse3-dev p7zip-full p7zip-rar
run: sudo apt-get install -y build-essential cmake libfuse3-dev 7zip

- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "3rdparty/p7zip"]
path = 3rdparty/p7zip
url = https://github.com/btolab/p7zip.git
[submodule "3rdparty/7zip"]
path = 3rdparty/7zip
url = https://github.com/ip7z/7zip.git
6 changes: 3 additions & 3 deletions .local.vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ if !exists("g:ale_configs_updated")
\"-I /usr/include/fuse3",
\"-I ".s:root."/include",
\"-I ".s:root."/src/include",
\"-I ".s:root."/3rdparty/p7zip",
\"-I ".s:root."/3rdparty/p7zip/CPP",
\"-I ".s:root."/3rdparty/p7zip/CPP/include_windows",
\"-I ".s:root."/3rdparty/7zip",
\"-I ".s:root."/3rdparty/7zip/CPP",
\"-I ".s:root."/3rdparty/7zip/CPP/include_windows",
\"-I ".s:root."/src/7zip/include",
\"-D_FILE_OFFSET_BITS=64"
\]
Expand Down
1 change: 1 addition & 0 deletions 3rdparty/7zip
Submodule 7zip added at e5431f
1 change: 0 additions & 1 deletion 3rdparty/p7zip
Submodule p7zip deleted from f30c85
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required (VERSION 3.12 FATAL_ERROR)

project (fuse3-p7zip
VERSION 1.2.3
DESCRIPTION "fuse3 file system that uses the p7zip library to mount archives"
VERSION 2.0.0
DESCRIPTION "fuse3 file system that uses the 7zip library to mount archives"
LANGUAGES CXX
)

Expand Down Expand Up @@ -53,8 +53,8 @@ add_executable ("${PROJECT_NAME}"
src/7zip/ReadStream.cpp
src/7zip/WriteStream.cpp
src/7zip/com.cpp
3rdparty/p7zip/CPP/Common/MyWindows.cpp
3rdparty/p7zip/CPP/Windows/PropVariant.cpp
3rdparty/7zip/CPP/Common/MyWindows.cpp
3rdparty/7zip/CPP/Windows/PropVariant.cpp
)

if ("${CMAKE_BUILD_TYPE}" MATCHES "Release")
Expand All @@ -81,10 +81,10 @@ target_include_directories ("${PROJECT_NAME}" PRIVATE
target_include_directories ("${PROJECT_NAME}" PRIVATE
src/include
"${FUSE3_INCLUDE_DIR}"
"${CMAKE_CURRENT_LIST_DIR}/3rdparty/p7zip"
"${CMAKE_CURRENT_LIST_DIR}/3rdparty/p7zip/CPP"
"${CMAKE_CURRENT_LIST_DIR}/3rdparty/p7zip/CPP/include_windows"
"${CMAKE_CURRENT_LIST_DIR}/3rdparty/p7zip/CPP/myWindows"
"${CMAKE_CURRENT_LIST_DIR}/3rdparty/7zip"
"${CMAKE_CURRENT_LIST_DIR}/3rdparty/7zip/CPP"
"${CMAKE_CURRENT_LIST_DIR}/3rdparty/7zip/CPP/include_windows"
"${CMAKE_CURRENT_LIST_DIR}/3rdparty/7zip/CPP/myWindows"
)
target_link_libraries ("${PROJECT_NAME}" PRIVATE
"${CMAKE_DL_LIBS}"
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Build system is based on CMake scripts, make and gcc/clang compilers.

All source code files are formatted with clang-format based on .clang-format configuration in the project

Include files of p7zip library are provided by git submodule `3rdparty/p7zip`
Include files of 7zip library are provided by git submodule `3rdparty/7zip`

## Setup

* Install modern c++ compiler with -std=c++20 support
* Install cmake
* Install fuse3 (devel package)
* Install p7zip (devel package)
* Install 7zip (devel package)

## Build

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Abstract

fuse3 file system that uses the p7zip library to mount archives (read only)
fuse3 file system that uses the 7zip library to mount archives (read only)

## Synopsis

Expand All @@ -25,7 +25,7 @@ mount any archive supported by 7zip as a filesystem mountpoint and have read onl

* Linux
* fuse3
* p7zip
* 7zip

## Enforcing codepage by renaming archive

Expand All @@ -49,7 +49,7 @@ Provide a path to a file with a password which will be used if archive is protec

* FUSE3_P7ZIP_LIBRARY

Change where application searches for 7z.so library. By default this is `/usr/lib/p7zip/7z.so`
Change where application searches for 7z.so library. By default this is `/usr/lib/7zip/7z.so`

* FUSE3_P7ZIP_PASSWORD

Expand Down
8 changes: 4 additions & 4 deletions src/7zip/Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace sevenzip {
return ret;
}

HRESULT WINAPI ImplArchive::SetTotal(const UInt64* files, const UInt64* bytes)
HRESULT WINAPI ImplArchive::SetTotal(const UInt64* files, const UInt64* bytes) noexcept
{
UNUSED(files);
UNUSED(bytes);
Expand All @@ -94,7 +94,7 @@ namespace sevenzip {
return ret;
}

HRESULT WINAPI ImplArchive::SetCompleted(const UInt64* files, const UInt64* bytes)
HRESULT WINAPI ImplArchive::SetCompleted(const UInt64* files, const UInt64* bytes) noexcept
{
UNUSED(files);
UNUSED(bytes);
Expand All @@ -103,7 +103,7 @@ namespace sevenzip {
return ret;
}

HRESULT WINAPI ImplArchive::CryptoGetTextPassword(BSTR* pass)
HRESULT WINAPI ImplArchive::CryptoGetTextPassword(BSTR* pass) noexcept
{
LogDebug("%s %p", __PRETTY_FUNCTION__, pass);
*pass = SysAllocString(wide_str(callback.request_password().c_str()).c_str());
Expand Down Expand Up @@ -236,7 +236,7 @@ namespace sevenzip {
ImplArchive::ci_iterator ImplArchive::ci_iterator::operator++(int)
{
ci_iterator ret(*this);
operator++();
operator++();
return ret;
}

Expand Down
13 changes: 7 additions & 6 deletions src/7zip/ArchiveExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace sevenzip {
, total()
{}

HRESULT WINAPI ImplArchiveExtractor::SetTotal(UInt64 size)
HRESULT WINAPI ImplArchiveExtractor::SetTotal(UInt64 size) noexcept
{
LogDebug("%s: %d", __PRETTY_FUNCTION__, size);
total = size;
Expand All @@ -51,7 +51,7 @@ namespace sevenzip {
return ret;
}

HRESULT WINAPI ImplArchiveExtractor::SetCompleted(const UInt64* completeValue)
HRESULT WINAPI ImplArchiveExtractor::SetCompleted(const UInt64* completeValue) noexcept
{
LogDebug("%s: %p %llu", __PRETTY_FUNCTION__, completeValue, *completeValue);
HRESULT ret = S_OK;
Expand All @@ -61,7 +61,8 @@ namespace sevenzip {
return ret;
}

HRESULT WINAPI ImplArchiveExtractor::GetStream(UInt32 index, ISequentialOutStream** outStream, Int32 askExtractMode)
HRESULT WINAPI ImplArchiveExtractor::GetStream(UInt32 index, ISequentialOutStream** outStream,
Int32 askExtractMode) noexcept
{
LogDebug("%s: %d %d %p", __PRETTY_FUNCTION__, index, askExtractMode, file.get());
*outStream = nullptr;
Expand Down Expand Up @@ -99,7 +100,7 @@ namespace sevenzip {
return S_OK;
}

HRESULT WINAPI ImplArchiveExtractor::PrepareOperation(Int32 askExtractMode)
HRESULT WINAPI ImplArchiveExtractor::PrepareOperation(Int32 askExtractMode) noexcept
{
LogDebug("%s: %d", __PRETTY_FUNCTION__, askExtractMode);
switch (askExtractMode) {
Expand All @@ -110,7 +111,7 @@ namespace sevenzip {
return S_OK;
}

HRESULT WINAPI ImplArchiveExtractor::SetOperationResult(Int32 operationResult)
HRESULT WINAPI ImplArchiveExtractor::SetOperationResult(Int32 operationResult) noexcept
{
LogDebug("%s: %d", __PRETTY_FUNCTION__, operationResult);
if (operationResult != NArchive::NExtract::NOperationResult::kOK) {
Expand All @@ -127,7 +128,7 @@ namespace sevenzip {
return S_OK;
}

HRESULT WINAPI ImplArchiveExtractor::CryptoGetTextPassword(BSTR* pass)
HRESULT WINAPI ImplArchiveExtractor::CryptoGetTextPassword(BSTR* pass) noexcept
{
LogDebug("%s %p", __PRETTY_FUNCTION__, pass);
*pass = SysAllocString(wide_str(callback.request_password().c_str()).c_str());
Expand Down
5 changes: 3 additions & 2 deletions src/7zip/Library.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#ifndef INITGUID
#ifndef INITGUID
# define INITGUID
#endif

#include "CPP/myWindows/StdAfx.h"
/* #include "CPP/myWindows/StdAfx.h" */
#include "CPP/Common/Common.h"
#include "CPP/Windows/Defs.h"
#include "CPP/7zip/MyVersion.h"

Expand Down
6 changes: 3 additions & 3 deletions src/7zip/ReadStream.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "7zip-impl.hpp"
#include "7zip-impl.hpp"
#include "exception.hpp"

namespace sevenzip {
Expand Down Expand Up @@ -58,14 +58,14 @@ namespace sevenzip {
lstat(_path.c_str(), &_stat);
}

HRESULT WINAPI FileReadStream::Read(void* data, UInt32 size, UInt32* processedSize)
HRESULT WINAPI FileReadStream::Read(void* data, UInt32 size, UInt32* processedSize) noexcept
{
auto read = std::fread(data, 1, size, _file);
if (processedSize) *processedSize = read;
return check_error(_file);
}

HRESULT WINAPI FileReadStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64* newPosition)
HRESULT WINAPI FileReadStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64* newPosition) noexcept
{
if (std::fseek(_file, offset, seekOrigin) == 0) {
if (newPosition) *newPosition = std::ftell(_file);
Expand Down
8 changes: 4 additions & 4 deletions src/7zip/WriteStream.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "7zip-impl.hpp"
#include "7zip-impl.hpp"
#include "exception.hpp"
#include "logger.hpp"

Expand Down Expand Up @@ -59,7 +59,7 @@ namespace sevenzip {
return ret;
}

HRESULT WINAPI FileWriteStream::Write(const void* data, UInt32 size, UInt32* processedSize)
HRESULT WINAPI FileWriteStream::Write(const void* data, UInt32 size, UInt32* processedSize) noexcept
{
LogTrace();
DWORD written = std::fwrite(data, 1, size, _file);
Expand All @@ -68,7 +68,7 @@ namespace sevenzip {
return check_error(_file);
}

HRESULT WINAPI FileWriteStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64* newPosition)
HRESULT WINAPI FileWriteStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64* newPosition) noexcept
{
LogTrace();
std::fseek(_file, offset, seekOrigin);
Expand All @@ -78,7 +78,7 @@ namespace sevenzip {
return check_error(_file);
}

HRESULT WINAPI FileWriteStream::SetSize(UInt64 newSize)
HRESULT WINAPI FileWriteStream::SetSize(UInt64 newSize) noexcept
{
LogTrace();
auto pos = std::ftell(_file);
Expand Down
34 changes: 18 additions & 16 deletions src/include/7zip-impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include "library-impl.hpp"

#define ENV_HAVE_WCTYPE_H
#include "CPP/myWindows/StdAfx.h"
/* #include "CPP/myWindows/StdAfx.h" */
#include "CPP/Common/Common.h"
#include "CPP/Windows/Defs.h"
#include "CPP/7zip/MyVersion.h"
#include "CPP/7zip/Archive/IArchive.h"
Expand Down Expand Up @@ -36,10 +37,10 @@ namespace sevenzip {
HRESULT WINAPI QueryInterface(REFIID riid, void** object) override;

// ISequentialInStream
HRESULT WINAPI Read(void* data, UInt32 size, UInt32* processedSize) override;
HRESULT WINAPI Read(void* data, UInt32 size, UInt32* processedSize) noexcept override;

// IInStream
HRESULT WINAPI Seek(Int64 offset, UInt32 seekOrigin, UInt64* newPosition) override;
HRESULT WINAPI Seek(Int64 offset, UInt32 seekOrigin, UInt64* newPosition) noexcept override;

private:
Path _path;
Expand All @@ -63,11 +64,11 @@ namespace sevenzip {
HRESULT WINAPI QueryInterface(REFIID riid, void** object) override;

// ISequentialOutStream
HRESULT WINAPI Write(const void* data, UInt32 size, UInt32* processedSize) override;
HRESULT WINAPI Write(const void* data, UInt32 size, UInt32* processedSize) noexcept override;

// IOutStream
HRESULT WINAPI Seek(Int64 offset, UInt32 seekOrigin, UInt64* newPosition) override;
HRESULT WINAPI SetSize(UInt64 newSize) override;
HRESULT WINAPI Seek(Int64 offset, UInt32 seekOrigin, UInt64* newPosition) noexcept override;
HRESULT WINAPI SetSize(UInt64 newSize) noexcept override;

// IFile
uint64_t read(void* data, uint64_t size) override;
Expand Down Expand Up @@ -127,11 +128,11 @@ namespace sevenzip {
HRESULT WINAPI QueryInterface(REFIID riid, void** object) override;

// IArchiveOpenCallback
HRESULT WINAPI SetTotal(const UInt64* files, const UInt64* bytes) override;
HRESULT WINAPI SetCompleted(const UInt64* files, const UInt64* bytes) override;
HRESULT WINAPI SetTotal(const UInt64* files, const UInt64* bytes) noexcept override;
HRESULT WINAPI SetCompleted(const UInt64* files, const UInt64* bytes) noexcept override;

// ICryptoGetTextPassword
HRESULT WINAPI CryptoGetTextPassword(BSTR* password) override;
HRESULT WINAPI CryptoGetTextPassword(BSTR* password) noexcept override;

const Path& path() const noexcept override;
const Stat& stat() const noexcept override;
Expand All @@ -147,7 +148,7 @@ namespace sevenzip {
const_iterator at(size_t index) const override;

com::Object<IInArchive> operator->() const;
operator com::Object<IInArchive>() const;
operator com::Object<IInArchive>() const;

protected:
void open_archive(const ImplLib& lib);
Expand Down Expand Up @@ -194,16 +195,17 @@ namespace sevenzip {
HRESULT WINAPI QueryInterface(REFIID riid, void** object) override;

// IProgress
HRESULT WINAPI SetTotal(UInt64 size) override;
HRESULT WINAPI SetCompleted(const UInt64* completeValue) override;
HRESULT WINAPI SetTotal(UInt64 size) noexcept override;
HRESULT WINAPI SetCompleted(const UInt64* completeValue) noexcept override;

// IArchiveExtractCallback
HRESULT WINAPI GetStream(UInt32 index, ISequentialOutStream** outStream, Int32 askExtractMode) override;
HRESULT WINAPI PrepareOperation(Int32 askExtractMode) override;
HRESULT WINAPI SetOperationResult(Int32 resultEOperationResult) override;
HRESULT WINAPI GetStream(UInt32 index, ISequentialOutStream** outStream,
Int32 askExtractMode) noexcept override;
HRESULT WINAPI PrepareOperation(Int32 askExtractMode) noexcept override;
HRESULT WINAPI SetOperationResult(Int32 resultEOperationResult) noexcept override;

// ICryptoGetTextPassword
HRESULT WINAPI CryptoGetTextPassword(BSTR* pass) override;
HRESULT WINAPI CryptoGetTextPassword(BSTR* pass) noexcept override;

// IArchiveExtractor
void execute(bool test) override;
Expand Down
3 changes: 2 additions & 1 deletion src/include/com.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

#include <atomic>

#include "CPP/myWindows/StdAfx.h"
/* #include "CPP/myWindows/StdAfx.h" */
#include "CPP/Common/Common.h"

namespace com {
HRESULT ConvertErrorToHRESULT(LONG error);
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
int main(int argc, char** argv, char** env)
try {
auto override_library = std::getenv("FUSE3_P7ZIP_LIBRARY");
auto lib_path = sevenzip::Path(override_library ? override_library : "/usr/lib/p7zip/7z.so");
auto lib_path = sevenzip::Path(override_library ? override_library : "/usr/lib/7zip/7z.so");

// preload Rar codecs (this also can be done with LD_PRELOAD)
library::Dynamic rar_codec;
Expand Down

0 comments on commit 69088cd

Please sign in to comment.