Merge pull request #389 from YACReader/7zip-migration

7zip migration
This commit is contained in:
Luis Ángel San Martín
2023-07-19 12:15:37 +02:00
committed by GitHub
23 changed files with 343 additions and 546 deletions

View File

@ -52,9 +52,9 @@ If you are interested in contributing to the project the first step should be to
Contributions are not restricted to coding; you can help the project by bringing new UI/UX ideas, designing new assets, writing manuals or tutorials, translating the apps, etc. If you are interested in DevOps, YACReader uses Azure Pipelines for CI/CD, any improvements in that area are welcome. Testing pre-releases is also really appreciated. Contributions are not restricted to coding; you can help the project by bringing new UI/UX ideas, designing new assets, writing manuals or tutorials, translating the apps, etc. If you are interested in DevOps, YACReader uses Azure Pipelines for CI/CD, any improvements in that area are welcome. Testing pre-releases is also really appreciated.
#### Dev Setup #### Dev Setup
YACReader is developed in *c++/Qt*, so the first thing you need to do is to install a *C++* compiler or environment that supports at least *C++17* and *Qt*. In *Windows* I use *Visual Studio Community Edition 2019* as build system and in *macos* I use Xcode, but I do all the coding using *QtCreator*. The project is adding support to *Qt6* and it already compiles under it but it is not ready to ship, so you need to make sure that everything works in both *Qt5* and *Qt6*, you only need to install *Qt5* for now and *CI* will check that everything builds with *Qt6*. YACReader is developed in *c++/Qt*, so the first thing you need to do is to install a *C++* compiler or environment that supports at least *C++17* and *Qt*. In *Windows* I use *Visual Studio Community Edition 2019* as build system and in *macos* I use Xcode, but I do all the coding using *QtCreator*. The project support *Qt5* and *Qt6* at the moment so you need to make sure that everything works in both *Qt5* and *Qt6*, you only need to install one flavor of *Qt* and *CI* will check that everything builds with both, I recommend using *Qt6*.
The repo includes binaries for the dependencies needed for *Windows* (MSVC compiler) and *macos* (clang) but you need to configure *7zip/p7zip* dependency manually, please take a look at *compressed_archive/README_7zip.txt*. The repo includes binaries for the dependencies needed for *Windows* (MSVC compiler) and *macos* (clang) but you need to configure *7zip* dependency manually, please take a look at *compressed_archive/README_7zip.txt*.
##### Running and debugging ##### Running and debugging
YACReader needs to find its dependencies at runtime, make sure that *Qt* binaries are in your *PATH* and the third-party binaries are next to the executable. The best way to make sure you have all the third-party binaries in place is to check YACReader installation and copy the binaries in your output folder. YACReader needs to find its dependencies at runtime, make sure that *Qt* binaries are in your *PATH* and the third-party binaries are next to the executable. The best way to make sure you have all the third-party binaries in place is to check YACReader installation and copy the binaries in your output folder.

View File

@ -26,8 +26,8 @@ jobs:
choco install -y wget choco install -y wget
choco install innosetup choco install innosetup
mkdir $(Build.SourcesDirectory)\compressed_archive mkdir $(Build.SourcesDirectory)\compressed_archive
wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z1805-src.7z?raw=true" -O $(Build.SourcesDirectory)\compressed_archive\7z1805-src.7z wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z2301-src.7z?raw=true" -O $(Build.SourcesDirectory)\compressed_archive\7z2301-src.7z
7z x $(Build.SourcesDirectory)\compressed_archive\7z1805-src.7z -o$(Build.SourcesDirectory)\compressed_archive\lib7zip 7z x $(Build.SourcesDirectory)\compressed_archive\7z2301-src.7z -o$(Build.SourcesDirectory)\compressed_archive\lib7zip
wget "${{ parameters.vc_redist_url }}" -O $(Build.SourcesDirectory)\${{ parameters.vc_redist_file_name }} wget "${{ parameters.vc_redist_url }}" -O $(Build.SourcesDirectory)\${{ parameters.vc_redist_file_name }}
displayName: 'Install dependencies' displayName: 'Install dependencies'
- script: | - script: |

View File

@ -26,8 +26,8 @@ jobs:
choco install -y wget choco install -y wget
choco install innosetup choco install innosetup
mkdir $(Build.SourcesDirectory)\compressed_archive mkdir $(Build.SourcesDirectory)\compressed_archive
wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z1805-src.7z?raw=true" -O $(Build.SourcesDirectory)\compressed_archive\7z1805-src.7z wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z2301-src.7z?raw=true" -O $(Build.SourcesDirectory)\compressed_archive\7z2301-src.7z
7z x $(Build.SourcesDirectory)\compressed_archive\7z1805-src.7z -o$(Build.SourcesDirectory)\compressed_archive\lib7zip 7z x $(Build.SourcesDirectory)\compressed_archive\7z2301-src.7z -o$(Build.SourcesDirectory)\compressed_archive\lib7zip
wget "${{ parameters.vc_redist_url }}" -O $(Build.SourcesDirectory)\${{ parameters.vc_redist_file_name }} wget "${{ parameters.vc_redist_url }}" -O $(Build.SourcesDirectory)\${{ parameters.vc_redist_file_name }}
displayName: 'Install dependencies' displayName: 'Install dependencies'
- script: | - script: |

View File

@ -111,10 +111,40 @@ jobs:
displayName: 'Run tests' displayName: 'Run tests'
# #
# MacOS qt6 # Linux qt6 7zip
# #
- job: MacOS_qt6 - job: Linux_qt6_7zip
timeoutInMinutes: 90
dependsOn: CodeFormatValidation
pool:
vmImage: 'ubuntu-22.04'
steps:
- script: |
sudo apt-get update
sudo apt-get install -y qtchooser qt6-tools-dev qt6-base-dev-tools qmake6 qmake6-bin \
qt6-base-dev qt6-multimedia-dev qt6-tools-dev-tools libgl-dev qt6-l10n-tools \
libqt6opengl6-dev libunarr-dev qt6-declarative-dev libqt6svg6-dev libqt6core5compat6-dev
mkdir $(Build.SourcesDirectory)\compressed_archive
wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z2301-src.7z?raw=true" -O $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z
7z x $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z -o$(Build.SourcesDirectory)/compressed_archive/lib7zip
displayName: 'Install dependencies'
- script: |
qtchooser -list-versions
export DEFINES_VAR=DEFINES+\=\"BUILD_NUMBER=\\\\\\\"$(Build.BuildNumber)\\\\\\\"\"
qmake6 CONFIG+="7zip no_pdf" $DEFINES_VAR
qmake6 -v
make
displayName: 'Build'
- script: |
make check TESTARGS="-maxwarnings 100000"
displayName: 'Run tests'
#
# MacOS qt6(intel)
#
- job: MacOS_qt6_Intel
timeoutInMinutes: 90 timeoutInMinutes: 90
dependsOn: CodeFormatValidation dependsOn: CodeFormatValidation
variables: variables:
@ -132,9 +162,8 @@ jobs:
brew link --overwrite node brew link --overwrite node
npm install -g appdmg npm install -g appdmg
mkdir $(Build.SourcesDirectory)\compressed_archive mkdir $(Build.SourcesDirectory)\compressed_archive
wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/p7zip_16.02_src_all.tar.bz2?raw=true" -O $(Build.SourcesDirectory)/compressed_archive/p7zip_16.02_src_all.tar.bz2 wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z2301-src.7z?raw=true" -O $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z
tar xjf $(Build.SourcesDirectory)/compressed_archive/p7zip_16.02_src_all.tar.bz2 -C $(Build.SourcesDirectory)/compressed_archive 7z x $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z -o$(Build.SourcesDirectory)/compressed_archive/lib7zip
mv $(Build.SourcesDirectory)/compressed_archive/p7zip_16.02 $(Build.SourcesDirectory)/compressed_archive/libp7zip
displayName: 'Install dependencies' displayName: 'Install dependencies'
- ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}: - ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}:
- task: InstallAppleCertificate@2 - task: InstallAppleCertificate@2
@ -146,7 +175,7 @@ jobs:
VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )" VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )"
echo "Trying to know if we are in a forked repo: $IS_FORK" echo "Trying to know if we are in a forked repo: $IS_FORK"
SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")" SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")"
./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN Qt6 ./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN Qt6 x86_64
displayName: 'Build' displayName: 'Build'
- script: | - script: |
cd $(Build.SourcesDirectory)/tests cd $(Build.SourcesDirectory)/tests
@ -167,7 +196,66 @@ jobs:
- task: PublishPipelineArtifact@1 - task: PublishPipelineArtifact@1
inputs: inputs:
path: $(Build.ArtifactStagingDirectory) path: $(Build.ArtifactStagingDirectory)
artifactName: Macos qt6 $(Build.BuildNumber) dmg artifactName: Macos qt6 Intel $(Build.BuildNumber) dmg
#
# MacOS qt6(apple)
#
#TODO create a template
- job: MacOS_qt6_Apple
timeoutInMinutes: 90
dependsOn: CodeFormatValidation
variables:
- ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}:
- group: macos-codesign
pool:
vmImage: 'macOS-latest'
steps:
- script: |
pip3 install aqtinstall
python3 -m aqt install 6.3.1 mac desktop -m qt5compat qtmultimedia qtimageformats
echo '##vso[task.prependpath]$(Build.SourcesDirectory)/6.3.1/macos/bin'
brew install create-dmg
brew install node
brew link --overwrite node
npm install -g appdmg
mkdir $(Build.SourcesDirectory)\compressed_archive
wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z2301-src.7z?raw=true" -O $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z
7z x $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z -o$(Build.SourcesDirectory)/compressed_archive/lib7zip
displayName: 'Install dependencies'
- ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}:
- task: InstallAppleCertificate@2
inputs:
certSecureFile: 'developerID_application.p12'
certPwd: $(P12Password)
- script: |
cd $(Build.SourcesDirectory)
VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )"
echo "Trying to know if we are in a forked repo: $IS_FORK"
SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")"
./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN Qt6 arm64
displayName: 'Build'
- script: |
cd $(Build.SourcesDirectory)/tests
qmake
make check TESTARGS="-maxwarnings 100000"
displayName: 'Build and run tests'
- script: |
SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")"
if [ "$SKIP_CODESIGN" = false ]; then
xcrun notarytool submit *.dmg --apple-id $(AppleId) --team-id $(TeamId) --password $(AppPassword) --wait
xcrun stapler staple *.dmg
fi
displayName: 'Notarize'
- task: CopyFiles@2
inputs:
contents: '*.dmg'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishPipelineArtifact@1
inputs:
path: $(Build.ArtifactStagingDirectory)
artifactName: Macos qt6 Apple $(Build.BuildNumber) dmg
# #
# MacOS # MacOS
@ -190,9 +278,8 @@ jobs:
brew link --overwrite node brew link --overwrite node
npm install -g appdmg npm install -g appdmg
mkdir $(Build.SourcesDirectory)\compressed_archive mkdir $(Build.SourcesDirectory)\compressed_archive
wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/p7zip_16.02_src_all.tar.bz2?raw=true" -O $(Build.SourcesDirectory)/compressed_archive/p7zip_16.02_src_all.tar.bz2 wget "https://github.com/YACReader/yacreader-7z-deps/blob/main/7z2301-src.7z?raw=true" -O $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z
tar xjf $(Build.SourcesDirectory)/compressed_archive/p7zip_16.02_src_all.tar.bz2 -C $(Build.SourcesDirectory)/compressed_archive 7z x $(Build.SourcesDirectory)/compressed_archive/7z2301-src.7z -o$(Build.SourcesDirectory)/compressed_archive/lib7zip
mv $(Build.SourcesDirectory)/compressed_archive/p7zip_16.02 $(Build.SourcesDirectory)/compressed_archive/libp7zip
displayName: 'Install dependencies' displayName: 'Install dependencies'
- ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}: - ${{ if and(eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/luisangelsm/'), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))) }}:
- task: InstallAppleCertificate@2 - task: InstallAppleCertificate@2
@ -204,7 +291,7 @@ jobs:
VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )" VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )"
echo "Trying to know if we are in a forked repo: $IS_FORK" echo "Trying to know if we are in a forked repo: $IS_FORK"
SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")" SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$IS_FORK")"
./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN Qt5 ./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN Qt5 x86_64
displayName: 'Build' displayName: 'Build'
- script: | - script: |
cd $(Build.SourcesDirectory)/tests cd $(Build.SourcesDirectory)/tests
@ -280,8 +367,11 @@ jobs:
- job: PublishDevBuilds - job: PublishDevBuilds
dependsOn: dependsOn:
- Linux - Linux
- Linux_qt6
- Linux_qt6_7zip
- MacOS - MacOS
- MacOS_qt6 - MacOS_qt6_Apple
- MacOS_qt6_Intel
- Windows_x86 - Windows_x86
- Windows_x64 - Windows_x64
- Windows_x64_qt6 - Windows_x64_qt6
@ -320,8 +410,11 @@ jobs:
- job: Release - job: Release
dependsOn: dependsOn:
- Linux - Linux
- Linux_qt6
- Linux_qt6_7zip
- MacOS - MacOS
- MacOS_qt6 - MacOS_qt6_Apple
- MacOS_qt6_Intel
- Windows_x86 - Windows_x86
- Windows_x64 - Windows_x64
- Windows_x64_qt6 - Windows_x64_qt6

View File

@ -9,29 +9,42 @@ SKIP_CODESIGN=${3:-false}
QT_VERSION=${4:-""} QT_VERSION=${4:-""}
echo "building macos binaries with these params: ${VERSION} ${BUILD_NUMBER} ${SKIP_CODESIGN} ${QT_VERSION}" ARCH=${5:-"arm64"}
if [ "$5" == "clean" ]; then echo "building macos binaries with these params: ${VERSION} ${BUILD_NUMBER} ${SKIP_CODESIGN} ${QT_VERSION} ${ARCH}"
./cleanOSX.sh
if [ "$6" == "clean" ]; then
./cleanOSX.sh
fi fi
if [ "$ARCH" == "arm64" ]; then
ARCH_NAME="Apple"
elif [ "$ARCH" == "x86_64" ]; then
ARCH_NAME="Intel"
else
echo "Unknown arch: $ARCH"
exit 1
fi
echo "Building for $ARCH_NAME"
hash qmake 2>/dev/null || { echo >&2 "Qmake command not available. Please add the bin subfolder of your Qt installation to the PATH environment variable."; exit 1; } hash qmake 2>/dev/null || { echo >&2 "Qmake command not available. Please add the bin subfolder of your Qt installation to the PATH environment variable."; exit 1; }
echo "Compiling YACReader" echo "Compiling YACReader"
cd YACReader cd YACReader
qmake DEFINES+="BUILD_NUMBER=\\\\\\\"${BUILD_NUMBER}\\\\\\\"" qmake DEFINES+="BUILD_NUMBER=\\\\\\\"${BUILD_NUMBER}\\\\\\\"" QMAKE_APPLE_DEVICE_ARCHS="${ARCH}"
make make
cd .. cd ..
echo "Compiling YACReaderLibrary" echo "Compiling YACReaderLibrary"
cd YACReaderLibrary cd YACReaderLibrary
qmake DEFINES+="BUILD_NUMBER=\\\\\\\"${BUILD_NUMBER}\\\\\\\"" qmake DEFINES+="BUILD_NUMBER=\\\\\\\"${BUILD_NUMBER}\\\\\\\"" QMAKE_APPLE_DEVICE_ARCHS="${ARCH}"
make make
cd .. cd ..
echo "Compiling YACReaderLibraryServer" echo "Compiling YACReaderLibraryServer"
cd YACReaderLibraryServer cd YACReaderLibraryServer
qmake DEFINES+="BUILD_NUMBER=\\\\\\\"${BUILD_NUMBER}\\\\\\\"" qmake DEFINES+="BUILD_NUMBER=\\\\\\\"${BUILD_NUMBER}\\\\\\\"" QMAKE_APPLE_DEVICE_ARCHS="${ARCH}"
make make
cd .. cd ..
@ -53,9 +66,9 @@ mkdir -p YACReader.app/Contents/MacOS/utils
mkdir -p YACReaderLibrary.app/Contents/MacOS/utils mkdir -p YACReaderLibrary.app/Contents/MacOS/utils
mkdir -p YACReaderLibraryServer.app/Contents/MacOS/utils mkdir -p YACReaderLibraryServer.app/Contents/MacOS/utils
cp -R dependencies/7zip/macx/* YACReader.app/Contents/MacOS/utils/ cp -R dependencies/7zip/macx/${ARCH}/* YACReader.app/Contents/MacOS/utils/
cp -R dependencies/7zip/macx/* YACReaderLibrary.app/Contents/MacOS/utils/ cp -R dependencies/7zip/macx/${ARCH}/* YACReaderLibrary.app/Contents/MacOS/utils/
cp -R dependencies/7zip/macx/* YACReaderLibraryServer.app/Contents/MacOS/utils/ cp -R dependencies/7zip/macx/${ARCH}/* YACReaderLibraryServer.app/Contents/MacOS/utils/
cp -R release/server YACReaderLibrary.app/Contents/MacOS/ cp -R release/server YACReaderLibrary.app/Contents/MacOS/
cp -R release/server YACReaderLibraryServer.app/Contents/MacOS/ cp -R release/server YACReaderLibraryServer.app/Contents/MacOS/
@ -74,7 +87,7 @@ fi
echo "Preparing apps for release, Done." echo "Preparing apps for release, Done."
dest="YACReader-$VERSION.$BUILD_NUMBER MacOSX-Intel ${QT_VERSION}" dest="YACReader-$VERSION.$BUILD_NUMBER MacOSX-$ARCH_NAME ${QT_VERSION}"
echo "Copying to destination folder ${dest}" echo "Copying to destination folder ${dest}"
mkdir -p "$dest" mkdir -p "$dest"
cp -R YACReader.app "${dest}/YACReader.app" cp -R YACReader.app "${dest}/YACReader.app"
@ -98,6 +111,7 @@ echo "Creating dmg package"
sed -i'' -e "s/#VERSION#/$VERSION/g" dmg.json sed -i'' -e "s/#VERSION#/$VERSION/g" dmg.json
sed -i'' -e "s/#BUILD_NUMBER#/$BUILD_NUMBER/g" dmg.json sed -i'' -e "s/#BUILD_NUMBER#/$BUILD_NUMBER/g" dmg.json
sed -i'' -e "s/#QT_VERSION#/$QT_VERSION/g" dmg.json sed -i'' -e "s/#QT_VERSION#/$QT_VERSION/g" dmg.json
sed -i'' -e "s/#ARCH_NAME#/$ARCH_NAME/g" dmg.json
appdmg dmg.json "$dest.dmg" appdmg dmg.json "$dest.dmg"
if [ "$SKIP_CODESIGN" = false ]; then if [ "$SKIP_CODESIGN" = false ]; then

View File

@ -1,8 +1,6 @@
#ifndef _7Z_INCLUDES_H #ifndef _7Z_INCLUDES_H
#define _7Z_INCLUDES_H #define _7Z_INCLUDES_H
// WIN includes
#ifdef Q_OS_WIN
extern "C" { extern "C" {
#include "lib7zip/C/Alloc.h" #include "lib7zip/C/Alloc.h"
#include "lib7zip/C/7zTypes.h" #include "lib7zip/C/7zTypes.h"
@ -22,53 +20,14 @@ extern "C" {
#include "lib7zip/CPP/7zip/IPassword.h" #include "lib7zip/CPP/7zip/IPassword.h"
#include "lib7zip/CPP/7zip/MyVersion.h" #include "lib7zip/CPP/7zip/MyVersion.h"
#include "lib7zip/CPP/Windows/FileDir.h"
#include "lib7zip/CPP/Windows/FileFind.h"
#include "lib7zip/CPP/Windows/FileName.h"
#include "lib7zip/CPP/Windows/NtCheck.h"
#include "lib7zip/CPP/Windows/PropVariant.h" #include "lib7zip/CPP/Windows/PropVariant.h"
#include "lib7zip/CPP/Windows/PropVariantConv.h" #include "lib7zip/CPP/Windows/PropVariantConv.h"
#include "lib7zip/CPP/7zip/Common/StreamObjects.h" #include "lib7zip/CPP/7zip/Common/StreamObjects.h"
#include "lib7zip/CPP/7zip/Common/StreamUtils.h" #include "lib7zip/CPP/7zip/Common/StreamUtils.h"
#else
// POSIX includes
extern "C" {
#include "libp7zip/C/Alloc.h"
#include "libp7zip/C/7zTypes.h"
}
#include "libp7zip/CPP/Windows/Defs.h"
#include "libp7zip/CPP/Common/Common.h"
#include "libp7zip/CPP/Common/MyCom.h"
// macos
// typedef int BOOL; ---> typedef signed char BOOL;
#include "libp7zip/CPP/include_windows/windows.h"
#include "libp7zip/CPP/include_windows/basetyps.h"
#include "libp7zip/CPP/include_windows/tchar.h"
#include "libp7zip/CPP/Common/MyWindows.h"
#include "libp7zip/CPP/Common/StringConvert.h"
#include "libp7zip/CPP/7zip/Archive/IArchive.h"
#include "libp7zip/CPP/7zip/IStream.h"
#include "libp7zip/CPP/7zip/IPassword.h"
#include "libp7zip/CPP/7zip/IProgress.h"
#include "libp7zip/CPP/7zip/Common/FileStreams.h"
#include "libp7zip/CPP/7zip/MyVersion.h"
#include "libp7zip/CPP/Windows/PropVariant.h"
#include "libp7zip/CPP/Windows/PropVariantConv.h"
#include "libp7zip/CPP/7zip/Common/StreamObjects.h"
#include "libp7zip/CPP/7zip/Common/StreamUtils.h"
#include "libp7zip/CPP/7zip/ICoder.h"
#endif
#endif // _7Z_INCLUDES_H #endif // _7Z_INCLUDES_H

View File

@ -1,10 +0,0 @@
#ifndef _7Z_PRECOMPILED_HEADER_H
#define _7Z_PRECOMPILED_HEADER_H
#if defined __cplusplus
#include "libp7zip/CPP/myWindows/StdAfx.h"
#endif
#endif // 7Z_PRECOMPILED_HEADER_H

View File

@ -1,7 +1,17 @@
If you are trying to compile YACReader with a 7zip decompression backend, If you are trying to compile YACReader with a 7zip decompression backend,
you need to download the source code of 7zip 18.05 (Windows) or p7zip 16.02 (Linux/MacOSX). you need to download the source code of 7zip 23.01.
Please extract it and rename the folder to lib7zip (Windows) or libp7zip (Linux/MacOSX), Please extract it and rename the folder to lib7zip (Windows),
then copy it to $YACREADER_SRC/compressed_archive/ (this folder). then copy it to $YACREADER_SRC/compressed_archive/ (this folder).
7zip is the recommended library to use is you want support for 7zip files and rar5. 7zip is the recommended library to use is you want support for 7zip files and rar5.
The app needs to load 7z.dll/7z.so at runtime.
The repo includes prebuilt binaries for windows (7z.dll) and macos (7z.so), check dependencies/7zip.
TODO: build 7z.so for macos with asm support (faster). Format7zF bundle (all supported formats enabled)
TODO: build 7z.so for linux (x86, x86_64, arm, arm64) with asm support (faster). Format7zF bundle (all supported formats enabled)
Please, open a PR if you are able to build 7z.so.

View File

@ -1,7 +1,4 @@
#include <QtCore> #include <QtCore>
#ifndef Q_OS_WIN
#include "libp7zip/CPP/Common/MyInitGuid.h"
#endif
#include "compressed_archive.h" #include "compressed_archive.h"
#include "extract_delegate.h" #include "extract_delegate.h"
@ -15,12 +12,9 @@
#include "extract_callbacks.h" #include "extract_callbacks.h"
#include "7z_includes.h" #include "7z_includes.h"
#include "lib7zip/CPP/Common/MyInitGuid.h"
#ifdef Q_OS_WIN
#define _MY_WINAPI WINAPI #define _MY_WINAPI WINAPI
#else
#define _MY_WINAPI
#endif
typedef quint32(_MY_WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *interfaceID, void **outObject); typedef quint32(_MY_WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *interfaceID, void **outObject);
typedef quint32(_MY_WINAPI *GetMethodPropertyFunc)(quint32 index, PROPID propID, PROPVARIANT *value); typedef quint32(_MY_WINAPI *GetMethodPropertyFunc)(quint32 index, PROPID propID, PROPVARIANT *value);
@ -57,23 +51,12 @@ DEFINE_GUID(CLSID_CFormatSplit, 0x23170f69, 0x40c1, 0x278a, 0x10, 0x00, 0x00,
DEFINE_GUID(CLSID_CFormatWim, 0x23170f69, 0x40c1, 0x278a, 0x10, 0x00, 0x00, 0x01, 0x10, 0xe6, 0x00, 0x00); DEFINE_GUID(CLSID_CFormatWim, 0x23170f69, 0x40c1, 0x278a, 0x10, 0x00, 0x00, 0x01, 0x10, 0xe6, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatZ, 0x23170f69, 0x40c1, 0x278a, 0x10, 0x00, 0x00, 0x01, 0x10, 0x05, 0x00, 0x00);*/ DEFINE_GUID(CLSID_CFormatZ, 0x23170f69, 0x40c1, 0x278a, 0x10, 0x00, 0x00, 0x01, 0x10, 0x05, 0x00, 0x00);*/
#ifdef Q_OS_WIN
GUID _supportedFileFormats[] = { CLSID_CFormatRar, CLSID_CFormatZip, CLSID_CFormatTar, CLSID_CFormat7z, CLSID_CFormatArj, CLSID_CFormatRar5 }; GUID _supportedFileFormats[] = { CLSID_CFormatRar, CLSID_CFormatZip, CLSID_CFormatTar, CLSID_CFormat7z, CLSID_CFormatArj, CLSID_CFormatRar5 };
#else
GUID _supportedFileFormats[] = { CLSID_CFormatZip, CLSID_CFormatTar, CLSID_CFormat7z, CLSID_CFormatArj };
#endif
std::vector<GUID> supportedFileFormats(_supportedFileFormats, _supportedFileFormats + sizeof(_supportedFileFormats) / sizeof(_supportedFileFormats[0])); std::vector<GUID> supportedFileFormats(_supportedFileFormats, _supportedFileFormats + sizeof(_supportedFileFormats) / sizeof(_supportedFileFormats[0]));
DEFINE_GUID(IID_InArchive, 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x06, 0x00, 0x60, 0x00, 0x00); DEFINE_GUID(IID_InArchive, 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x06, 0x00, 0x60, 0x00, 0x00);
DEFINE_GUID(IID_ISetCompressCodecsInfoX, 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x61, 0x00, 0x00); DEFINE_GUID(IID_ISetCompressCodecsInfoX, 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x61, 0x00, 0x00);
/*#ifdef Q_OS_UNIX
DEFINE_GUID(IID_IOutStream, 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00);
DEFINE_GUID(IID_IInStream, 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00);
DEFINE_GUID(IID_IStreamGetSize, 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00);
DEFINE_GUID(IID_ISequentialInStream, 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00);
#endif*/
struct SevenZipInterface { struct SevenZipInterface {
CreateObjectFunc createObjectFunc; CreateObjectFunc createObjectFunc;
GetMethodPropertyFunc getMethodPropertyFunc; GetMethodPropertyFunc getMethodPropertyFunc;
@ -82,13 +65,6 @@ struct SevenZipInterface {
GetHandlerPropertyFunc getHandlerPropertyFunc; GetHandlerPropertyFunc getHandlerPropertyFunc;
GetHandlerPropertyFunc2 getHandlerPropertyFunc2; GetHandlerPropertyFunc2 getHandlerPropertyFunc2;
SetLargePageModeFunc setLargePageModeFunc; SetLargePageModeFunc setLargePageModeFunc;
#ifdef Q_OS_UNIX
CreateObjectFunc createObjectFuncRar;
GetMethodPropertyFunc getMethodPropertyFuncRar;
GetNumberOfMethodsFunc getNumberOfMethodsFuncRar;
#endif
CMyComPtr<IInArchive> archive; CMyComPtr<IInArchive> archive;
}; };
@ -103,10 +79,6 @@ const unsigned char arj[2] = { static_cast<unsigned char>(0x60), static_cast<uns
CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent) CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent)
: QObject(parent), sevenzLib(0), valid(false), tools(false) : QObject(parent), sevenzLib(0), valid(false), tools(false)
#ifdef Q_OS_UNIX
,
isRar(false)
#endif
{ {
szInterface = new SevenZipInterface; szInterface = new SevenZipInterface;
// load functions // load functions
@ -123,10 +95,8 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent)
CMyComPtr<IInStream> file = fileSpec; CMyComPtr<IInStream> file = fileSpec;
YCArchiveOpenCallback *openCallbackSpec = new YCArchiveOpenCallback; YCArchiveOpenCallback *openCallbackSpec = new YCArchiveOpenCallback;
CMyComPtr<IArchiveOpenCallback> openCallback = openCallbackSpec; CMyComPtr<IArchiveOpenCallback> openCallback(openCallbackSpec);
openCallbackSpec->PasswordIsDefined = false; openCallbackSpec->PasswordIsDefined = false;
// openCallbackSpec->PasswordIsDefined = true;
// openCallbackSpec->Password = L"1";
// get file type from suffix // get file type from suffix
int i = -1; int i = -1;
@ -135,36 +105,6 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent)
if (!filex.open(QIODevice::ReadOnly)) if (!filex.open(QIODevice::ReadOnly))
return; return;
QByteArray magicNumber = filex.read(8); // read first 8 bytes QByteArray magicNumber = filex.read(8); // read first 8 bytes
// if (memcmp(magicNumber,rar5,8)==0)
// return; //rar5 is not supported
// qDebug() << memcmp(magicNumber,rar,7);
// TODO: this suffix matching is rather primitive - better approach?
#ifdef Q_OS_UNIX
if (memcmp(magicNumber, rar, 6) != 0) {
// match suffix to GUID list
if (memcmp(magicNumber, zip, 2) == 0)
i = 0;
else if (memcmp(magicNumber, sevenz, 6) == 0)
i = 2;
else if (memcmp(magicNumber, arj, 2) == 0)
i = 3;
else {
filex.seek(257);
magicNumber = filex.read(8);
if (memcmp(magicNumber, tar, 5) == 0)
i = 1;
}
if (i == -1) // fallback code
{
QFileInfo fileinfo(filePath);
if (fileinfo.suffix() == "zip" || fileinfo.suffix() == "cbz") {
i = 0;
} else {
return;
}
}
#else
if (memcmp(magicNumber, rar, 6) == 0) if (memcmp(magicNumber, rar, 6) == 0)
if (memcmp(magicNumber, rar5, 7) == 0) if (memcmp(magicNumber, rar5, 7) == 0)
i = 5; i = 5;
@ -191,314 +131,197 @@ CompressedArchive::CompressedArchive(const QString &filePath, QObject *parent)
return; return;
} }
} }
#endif
#ifdef UNICODE #ifdef USE_UNICODE_FSTRING
if (!fileSpec->Open((LPCTSTR)filePath.toStdWString().c_str()))
#else
if (!fileSpec->Open((LPCTSTR)filePath.toStdString().c_str()))
#endif
{
qDebug() << "unable to load" + filePath;
return;
}
// GUID uuid = supportedFileFormats[i];
// qDebug() << "trying : " << uuid << endl;
if (szInterface->createObjectFunc(&supportedFileFormats[i], &IID_InArchive, (void **)&szInterface->archive) == S_OK) {
// qDebug() << "Can not open archive file : " + filePath << Qt::endl;
if (szInterface->archive->Open(file, 0, openCallback) == S_OK) {
valid = formatFound = true;
qDebug() << "Opened archive file : " + filePath << Qt::endl;
setupFilesNames();
return;
}
}
#ifdef Q_OS_WIN
if (!formatFound) {
qDebug() << "Can not open archive" << Qt::endl;
}
}
}
#else
} else {
// RAR in macos and unix
GUID clsidRar;
if (memcmp(magicNumber, rar5, 7) == 0) {
clsidRar = CLSID_CFormatRar5;
} else {
clsidRar = CLSID_CFormatRar;
}
isRar = true; // tell the destructor we *tried* to open a rar file!
if (szInterface->createObjectFunc(&clsidRar, &IID_InArchive, (void **)&szInterface->archive) != S_OK) {
qDebug() << "Error creating rar archive :" + filePath;
return;
}
CMyComPtr<ISetCompressCodecsInfo> codecsInfo;
if (szInterface->archive->QueryInterface(IID_ISetCompressCodecsInfoX, (void **)&codecsInfo) != S_OK) {
qDebug() << "Error getting rar codec :" + filePath;
return;
}
if (codecsInfo->SetCompressCodecsInfo(this) != S_OK) {
qDebug() << "Error setting rar codec";
return;
}
#ifdef UNICODE
if (!fileSpec->Open((LPCTSTR)filePath.toStdWString().c_str())) if (!fileSpec->Open((LPCTSTR)filePath.toStdWString().c_str()))
#else #else
if (!fileSpec->Open((LPCTSTR)filePath.toStdString().c_str())) if (!fileSpec->Open((LPCTSTR)filePath.toStdString().c_str()))
#endif #endif
{ {
qDebug() << "Error opening rar file :" + filePath; qDebug() << "unable to load" + filePath;
return; return;
} }
// qDebug() << "Can not open archive file : " + filePath << Qt::endl;
if (szInterface->archive->Open(file, 0, openCallback) == S_OK) { // GUID uuid = supportedFileFormats[i];
valid = formatFound = true; // qDebug() << "trying : " << uuid << endl;
setupFilesNames(); if (szInterface->createObjectFunc(&supportedFileFormats[i], &IID_InArchive, (void **)&szInterface->archive) == S_OK) {
// isRar = true; // qDebug() << "Can not open archive file : " + filePath << Qt::endl;
if (szInterface->archive->Open(file, 0, openCallback) == S_OK) {
valid = formatFound = true;
qDebug() << "Opened archive file : " + filePath << Qt::endl;
setupFilesNames();
return;
}
}
if (!formatFound) {
qDebug() << "Can not open archive" << Qt::endl;
} }
} }
} }
}
#endif
CompressedArchive::~CompressedArchive() CompressedArchive::~CompressedArchive()
{ {
// always close the archive! // always close the archive!
if (szInterface->archive) { if (szInterface->archive) {
szInterface->archive->Close(); szInterface->archive->Close();
}
#ifdef Q_OS_UNIX
if (isRar) // TODO: Memory leak!!!! If AddRef is not used, a crash occurs in "delete szInterface"
{
szInterface->archive->AddRef();
}
#endif
delete szInterface;
#ifdef Q_OS_UNIX
delete rarLib;
#endif
delete sevenzLib;
} }
bool CompressedArchive::loadFunctions() delete szInterface;
{ delete sevenzLib;
// LOAD library }
// TODO check if this works in OSX (7z.so instead of 7z.dylib)
// fix1: try to load "7z.so" bool CompressedArchive::loadFunctions()
// fix2: rename 7z.so to 7z.dylib {
if (sevenzLib == 0) { // LOAD library
#if defined Q_OS_UNIX if (sevenzLib == 0) {
#if defined Q_OS_MACOS
rarLib = new QLibrary(QCoreApplication::applicationDirPath() + "/utils/Codecs/Rar");
#else
// check if a yacreader specific version of p7zip exists on the system
QFileInfo rarCodec(QString(LIBDIR) + "/yacreader/Codecs/Rar.so");
if (rarCodec.exists()) {
rarLib = new QLibrary(rarCodec.absoluteFilePath());
} else {
rarLib = new QLibrary(QString(LIBDIR) + "/p7zip/Codecs/Rar.so");
}
#endif
if (!rarLib->load()) {
qDebug() << "Error Loading Rar.so : " + rarLib->errorString() << Qt::endl;
QCoreApplication::exit(700); // TODO yacreader_global can't be used here, it is GUI dependant, YACReader::SevenZNotFound
return false;
}
#endif
#if defined Q_OS_UNIX && !defined Q_OS_MACOS #if defined Q_OS_UNIX && !defined Q_OS_MACOS
QFileInfo sevenzlibrary(QString(LIBDIR) + "/yacreader/7z.so"); QFileInfo sevenzlibrary(QString(LIBDIR) + "/yacreader/7z.so");
if (sevenzlibrary.exists()) { if (sevenzlibrary.exists()) {
sevenzLib = new QLibrary(sevenzlibrary.absoluteFilePath()); sevenzLib = new QLibrary(sevenzlibrary.absoluteFilePath());
} else { } else {
sevenzLib = new QLibrary(QString(LIBDIR) + "/p7zip/7z.so"); sevenzLib = new QLibrary(QString(LIBDIR) + "/7zip/7z.so");
} }
#else #else
sevenzLib = new QLibrary(QCoreApplication::applicationDirPath() + "/utils/7z"); sevenzLib = new QLibrary(QCoreApplication::applicationDirPath() + "/utils/7z");
#endif #endif
} }
if (!sevenzLib->load()) { if (!sevenzLib->load()) {
qDebug() << "Error Loading 7z.dll : " + sevenzLib->errorString() << Qt::endl; qDebug() << "Error Loading 7z.dll : " + sevenzLib->errorString() << Qt::endl;
QCoreApplication::exit(700); // TODO yacreader_global can't be used here, it is GUI dependant, YACReader::SevenZNotFound QCoreApplication::exit(700); // TODO yacreader_global can't be used here, it is GUI dependant, YACReader::SevenZNotFound
return false; return false;
} else { } else {
qDebug() << "Loading functions" << Qt::endl; qDebug() << "Loading functions" << Qt::endl;
if ((szInterface->createObjectFunc = (CreateObjectFunc)sevenzLib->resolve("CreateObject")) == 0) if ((szInterface->createObjectFunc = (CreateObjectFunc)sevenzLib->resolve("CreateObject")) == 0)
qDebug() << "fail loading function : CreateObject" << Qt::endl; qDebug() << "fail loading function : CreateObject" << Qt::endl;
if ((szInterface->getMethodPropertyFunc = (GetMethodPropertyFunc)sevenzLib->resolve("GetMethodProperty")) == 0) if ((szInterface->getMethodPropertyFunc = (GetMethodPropertyFunc)sevenzLib->resolve("GetMethodProperty")) == 0)
qDebug() << "fail loading function : GetMethodProperty" << Qt::endl; qDebug() << "fail loading function : GetMethodProperty" << Qt::endl;
if ((szInterface->getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)sevenzLib->resolve("GetNumberOfMethods")) == 0) if ((szInterface->getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)sevenzLib->resolve("GetNumberOfMethods")) == 0)
qDebug() << "fail loading function : GetNumberOfMethods" << Qt::endl; qDebug() << "fail loading function : GetNumberOfMethods" << Qt::endl;
if ((szInterface->getNumberOfFormatsFunc = (GetNumberOfFormatsFunc)sevenzLib->resolve("GetNumberOfFormats")) == 0) if ((szInterface->getNumberOfFormatsFunc = (GetNumberOfFormatsFunc)sevenzLib->resolve("GetNumberOfFormats")) == 0)
qDebug() << "fail loading function : GetNumberOfFormats" << Qt::endl; qDebug() << "fail loading function : GetNumberOfFormats" << Qt::endl;
if ((szInterface->getHandlerPropertyFunc = (GetHandlerPropertyFunc)sevenzLib->resolve("GetHandlerProperty")) == 0) if ((szInterface->getHandlerPropertyFunc = (GetHandlerPropertyFunc)sevenzLib->resolve("GetHandlerProperty")) == 0)
qDebug() << "fail loading function : GetHandlerProperty" << Qt::endl; qDebug() << "fail loading function : GetHandlerProperty" << Qt::endl;
if ((szInterface->getHandlerPropertyFunc2 = (GetHandlerPropertyFunc2)sevenzLib->resolve("GetHandlerProperty2")) == 0) if ((szInterface->getHandlerPropertyFunc2 = (GetHandlerPropertyFunc2)sevenzLib->resolve("GetHandlerProperty2")) == 0)
qDebug() << "fail loading function : GetHandlerProperty2" << Qt::endl; qDebug() << "fail loading function : GetHandlerProperty2" << Qt::endl;
if ((szInterface->setLargePageModeFunc = (SetLargePageModeFunc)sevenzLib->resolve("SetLargePageMode")) == 0) if ((szInterface->setLargePageModeFunc = (SetLargePageModeFunc)sevenzLib->resolve("SetLargePageMode")) == 0)
qDebug() << "fail loading function : SetLargePageMode" << Qt::endl; qDebug() << "fail loading function : SetLargePageMode" << Qt::endl;
#ifdef Q_OS_UNIX
if ((szInterface->createObjectFuncRar = (CreateObjectFunc)rarLib->resolve("CreateObject")) == 0)
qDebug() << "fail loading function (rar) : CreateObject" << Qt::endl;
if ((szInterface->getMethodPropertyFuncRar = (GetMethodPropertyFunc)rarLib->resolve("GetMethodProperty")) == 0)
qDebug() << "fail loading function (rar) : GetMethodProperty" << Qt::endl;
if ((szInterface->getNumberOfMethodsFuncRar = (GetNumberOfMethodsFunc)rarLib->resolve("GetNumberOfMethods")) == 0)
qDebug() << "fail loading function (rar) : GetNumberOfMethods" << Qt::endl;
#endif
}
return true;
} }
void CompressedArchive::setupFilesNames() return true;
{ }
quint32 numItems = getNumEntries();
quint32 p = 0;
for (quint32 i = 0; i < numItems; i++) {
// Get name of file void CompressedArchive::setupFilesNames()
NWindows::NCOM::CPropVariant prop; {
szInterface->archive->GetProperty(i, kpidIsDir, &prop); quint32 numItems = getNumEntries();
bool isDir; quint32 p = 0;
if (prop.vt == VT_BOOL) for (quint32 i = 0; i < numItems; i++) {
isDir = VARIANT_BOOLToBool(prop.boolVal);
else if (prop.vt == VT_EMPTY)
isDir = false;
else
continue;
if (!isDir) { // Get name of file
szInterface->archive->GetProperty(i, kpidPath, &prop); NWindows::NCOM::CPropVariant prop;
UString s = prop.bstrVal; szInterface->archive->GetProperty(i, kpidIsDir, &prop);
const wchar_t *chars = s.operator const wchar_t *(); bool isDir;
files.append(QString::fromWCharArray(chars)); if (prop.vt == VT_BOOL)
offsets.append(i); isDir = VARIANT_BOOLToBool(prop.boolVal);
indexesToPages.insert(i, p); else if (prop.vt == VT_EMPTY)
p++; isDir = false;
} else
continue;
if (!isDir) {
szInterface->archive->GetProperty(i, kpidPath, &prop);
UString s = prop.bstrVal;
const wchar_t *chars = s.operator const wchar_t *();
files.append(QString::fromWCharArray(chars));
offsets.append(i);
indexesToPages.insert(i, p);
p++;
} }
} }
}
QVector<quint32> CompressedArchive::translateIndexes(const QVector<quint32> &indexes) QVector<quint32> CompressedArchive::translateIndexes(const QVector<quint32> &indexes)
{ {
QVector<quint32> translatedIndexes; QVector<quint32> translatedIndexes;
foreach (quint32 i, indexes) { foreach (quint32 i, indexes) {
if (i < (quint32)offsets.length()) if (i < (quint32)offsets.length())
translatedIndexes.append(offsets.at(i)); translatedIndexes.append(offsets.at(i));
}
return translatedIndexes;
} }
QList<QString> CompressedArchive::getFileNames() return translatedIndexes;
{ }
return files;
QList<QString> CompressedArchive::getFileNames()
{
return files;
}
bool CompressedArchive::isValid()
{
return valid;
}
bool CompressedArchive::toolsLoaded()
{
return tools;
}
int CompressedArchive::getNumFiles()
{
return files.length();
}
int CompressedArchive::getNumEntries()
{
quint32 numItems = 0;
szInterface->archive->GetNumberOfItems(&numItems);
return numItems;
}
QList<QByteArray> CompressedArchive::getAllData(const QVector<quint32> &indexes, ExtractDelegate *delegate)
{
YCArchiveExtractCallback *extractCallbackSpec = new YCArchiveExtractCallback(indexesToPages, true, delegate);
CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
extractCallbackSpec->Init(szInterface->archive, L""); // second parameter is output folder path
extractCallbackSpec->PasswordIsDefined = false;
QVector<quint32> currentIndexes = translateIndexes(indexes);
HRESULT result;
if (indexes.isEmpty())
result = szInterface->archive->Extract(NULL, -1, false, extractCallback);
else
result = szInterface->archive->Extract(currentIndexes.data(), currentIndexes.count(), false, extractCallback);
if (result != S_OK) {
qDebug() << "Extract Error" << Qt::endl;
} }
bool CompressedArchive::isValid() return extractCallbackSpec->allFiles;
{ }
return valid;
}
bool CompressedArchive::toolsLoaded() QByteArray CompressedArchive::getRawDataAtIndex(int index)
{ {
return tools; if (index >= 0 && index < getNumFiles()) {
} YCArchiveExtractCallback *extractCallbackSpec = new YCArchiveExtractCallback(indexesToPages);
int CompressedArchive::getNumFiles()
{
return files.length();
}
int CompressedArchive::getNumEntries()
{
quint32 numItems = 0;
szInterface->archive->GetNumberOfItems(&numItems);
return numItems;
}
QList<QByteArray> CompressedArchive::getAllData(const QVector<quint32> &indexes, ExtractDelegate *delegate)
{
YCArchiveExtractCallback *extractCallbackSpec = new YCArchiveExtractCallback(indexesToPages, true, delegate);
CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec); CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
extractCallbackSpec->Init(szInterface->archive, L""); // second parameter is output folder path extractCallbackSpec->Init(szInterface->archive, L""); // second parameter is output folder path
extractCallbackSpec->PasswordIsDefined = false; extractCallbackSpec->PasswordIsDefined = false;
QVector<quint32> currentIndexes = translateIndexes(indexes); UInt32 indices[1];
HRESULT result; if (index < offsets.length())
if (indexes.isEmpty()) indices[0] = offsets.at(index);
result = szInterface->archive->Extract(NULL, -1, false, extractCallback);
else else
result = szInterface->archive->Extract(currentIndexes.data(), currentIndexes.count(), false, extractCallback); indices[0] = index;
HRESULT result = szInterface->archive->Extract(indices, 1, false, extractCallback);
if (result != S_OK) { if (result != S_OK) {
qDebug() << "Extract Error" << Qt::endl; qDebug() << "Extract Error" << Qt::endl;
} }
return extractCallbackSpec->allFiles; return QByteArray((char *)extractCallbackSpec->data, extractCallbackSpec->newFileSize);
} }
return QByteArray();
QByteArray CompressedArchive::getRawDataAtIndex(int index) }
{
if (index >= 0 && index < getNumFiles()) {
YCArchiveExtractCallback *extractCallbackSpec = new YCArchiveExtractCallback(indexesToPages);
CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
extractCallbackSpec->Init(szInterface->archive, L""); // second parameter is output folder path
extractCallbackSpec->PasswordIsDefined = false;
UInt32 indices[1];
if (index < offsets.length())
indices[0] = offsets.at(index);
else
indices[0] = index;
HRESULT result = szInterface->archive->Extract(indices, 1, false, extractCallback);
if (result != S_OK) {
qDebug() << "Extract Error" << Qt::endl;
}
return QByteArray((char *)extractCallbackSpec->data, extractCallbackSpec->newFileSize);
}
return QByteArray();
}
#ifdef Q_OS_UNIX
STDMETHODIMP CompressedArchive::GetNumMethods(UInt32 * numMethods)
{
return szInterface->getNumberOfMethodsFuncRar(numMethods);
}
STDMETHODIMP CompressedArchive::GetProperty(UInt32 index, PROPID propID, PROPVARIANT * value)
{
return szInterface->getMethodPropertyFuncRar(index, propID, value);
}
int i = 0;
STDMETHODIMP CompressedArchive::CreateDecoder(UInt32 index, const GUID *interfaceID, void **coder)
{
NCOM::CPropVariant propVariant;
szInterface->getMethodPropertyFuncRar(index, NMethodPropID::kDecoder, &propVariant);
return szInterface->createObjectFuncRar((const GUID *)propVariant.bstrVal, interfaceID, coder);
}
STDMETHODIMP CompressedArchive::CreateEncoder(UInt32 index, const GUID *interfaceID, void **coder)
{
return S_OK; // szInterface->createObjectFuncRar(&CLSID_CFormatRar,interfaceID,coder);
}
#endif

View File

@ -3,11 +3,6 @@
#include <QObject> #include <QObject>
#ifdef Q_OS_UNIX
#include "libp7zip/CPP/7zip/ICoder.h"
#include "libp7zip/CPP/Common/MyCom.h"
#endif
class ExtractDelegate; class ExtractDelegate;
class QLibrary; class QLibrary;
@ -19,32 +14,13 @@ struct SevenZipInterface;
class MyCodecs; class MyCodecs;
#ifdef Q_OS_UNIX
class CompressedArchive : public QObject, public ICompressCodecsInfo, public CMyUnknownImp
#else
class CompressedArchive : public QObject class CompressedArchive : public QObject
#endif
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CompressedArchive(const QString &filePath, QObject *parent = 0); explicit CompressedArchive(const QString &filePath, QObject *parent = 0);
~CompressedArchive(); ~CompressedArchive();
#ifdef Q_OS_UNIX
MY_UNKNOWN_IMP
STDMETHOD(GetNumMethods)
(UInt32 *numMethods);
STDMETHOD(GetProperty)
(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(CreateDecoder)
(UInt32 index, const GUID *iid, void **coder);
STDMETHOD(CreateEncoder)
(UInt32 index, const GUID *iid, void **coder);
bool isRar;
#endif
signals: signals:
public slots: public slots:
@ -60,9 +36,6 @@ private:
SevenZipInterface *szInterface; SevenZipInterface *szInterface;
QLibrary *sevenzLib; QLibrary *sevenzLib;
#ifdef Q_OS_UNIX
QLibrary *rarLib;
#endif
bool loadFunctions(); bool loadFunctions();
bool tools; bool tools;
bool valid; bool valid;

View File

@ -44,26 +44,8 @@ class YCArchiveExtractCallback : public IArchiveExtractCallback,
public ICryptoGetTextPassword, public ICryptoGetTextPassword,
public CMyUnknownImp public CMyUnknownImp
{ {
public: Z7_IFACES_IMP_UNK_2(IArchiveExtractCallback, ICryptoGetTextPassword)
MY_UNKNOWN_IMP1(ICryptoGetTextPassword) Z7_IFACE_COM7_IMP(IProgress)
// IProgress
STDMETHOD(SetTotal)
(UInt64 size);
STDMETHOD(SetCompleted)
(const UInt64 *completeValue);
// IArchiveExtractCallback
STDMETHOD(GetStream)
(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode);
STDMETHOD(PrepareOperation)
(Int32 askExtractMode);
STDMETHOD(SetOperationResult)
(Int32 resultEOperationResult);
// ICryptoGetTextPassword
STDMETHOD(CryptoGetTextPassword)
(BSTR *aPassword);
private: private:
CMyComPtr<IInArchive> _archiveHandler; CMyComPtr<IInArchive> _archiveHandler;
@ -108,18 +90,18 @@ void YCArchiveExtractCallback::Init(IInArchive *archiveHandler, const UString &d
directoryPath; // unused directoryPath; // unused
} }
STDMETHODIMP YCArchiveExtractCallback::SetTotal(UInt64 /* size */) Z7_COM7F_IMF(YCArchiveExtractCallback::SetTotal(UInt64 /* size */))
{ {
return S_OK; return S_OK;
} }
STDMETHODIMP YCArchiveExtractCallback::SetCompleted(const UInt64 * /* completeValue */) Z7_COM7F_IMF(YCArchiveExtractCallback::SetCompleted(const UInt64 * /* completeValue */))
{ {
return S_OK; return S_OK;
} }
STDMETHODIMP YCArchiveExtractCallback::GetStream(UInt32 index, Z7_COM7F_IMF(YCArchiveExtractCallback::GetStream(UInt32 index,
ISequentialOutStream **outStream, Int32 askExtractMode) ISequentialOutStream **outStream, Int32 askExtractMode))
{ {
*outStream = 0; *outStream = 0;
_outFileStream.Release(); _outFileStream.Release();
@ -220,7 +202,7 @@ STDMETHODIMP YCArchiveExtractCallback::GetStream(UInt32 index,
}*/ }*/
if (newFileSizeDefined) { if (newFileSizeDefined) {
CBufPtrSeqOutStream *outStreamSpec = new CBufPtrSeqOutStream; CBufPtrSeqOutStream *outStreamSpec = new CBufPtrSeqOutStream;
CMyComPtr<CBufPtrSeqOutStream> outStreamLocal(outStreamSpec); CMyComPtr<ISequentialOutStream> outStreamLocal(outStreamSpec);
data = (Byte *)MidAlloc(newFileSize); data = (Byte *)MidAlloc(newFileSize);
outStreamSpec->Init(data, newFileSize); outStreamSpec->Init(data, newFileSize);
*outStream = outStreamLocal.Detach(); *outStream = outStreamLocal.Detach();
@ -230,7 +212,7 @@ STDMETHODIMP YCArchiveExtractCallback::GetStream(UInt32 index,
return S_OK; return S_OK;
} }
STDMETHODIMP YCArchiveExtractCallback::PrepareOperation(Int32 askExtractMode) Z7_COM7F_IMF(YCArchiveExtractCallback::PrepareOperation(Int32 askExtractMode))
{ {
_extractMode = false; _extractMode = false;
switch (askExtractMode) { switch (askExtractMode) {
@ -248,7 +230,7 @@ STDMETHODIMP YCArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
return S_OK; return S_OK;
} }
STDMETHODIMP YCArchiveExtractCallback::SetOperationResult(Int32 operationResult) Z7_COM7F_IMF(YCArchiveExtractCallback::SetOperationResult(Int32 operationResult))
{ {
switch (operationResult) { switch (operationResult) {
case NArchive::NExtract::NOperationResult::kOK: case NArchive::NExtract::NOperationResult::kOK:
@ -303,7 +285,7 @@ STDMETHODIMP YCArchiveExtractCallback::SetOperationResult(Int32 operationResult)
return S_OK; return S_OK;
} }
STDMETHODIMP YCArchiveExtractCallback::CryptoGetTextPassword(BSTR *password) Z7_COM7F_IMF(YCArchiveExtractCallback::CryptoGetTextPassword(BSTR *password))
{ {
if (!PasswordIsDefined) { if (!PasswordIsDefined) {
// You can ask real password here from user // You can ask real password here from user

View File

@ -10,17 +10,8 @@ class YCArchiveOpenCallback : public IArchiveOpenCallback,
public ICryptoGetTextPassword, public ICryptoGetTextPassword,
public CMyUnknownImp public CMyUnknownImp
{ {
Z7_IFACES_IMP_UNK_2(IArchiveOpenCallback, ICryptoGetTextPassword)
public: public:
MY_UNKNOWN_IMP1(ICryptoGetTextPassword)
STDMETHOD(SetTotal)
(const UInt64 *files, const UInt64 *bytes);
STDMETHOD(SetCompleted)
(const UInt64 *files, const UInt64 *bytes);
STDMETHOD(CryptoGetTextPassword)
(BSTR *password);
bool PasswordIsDefined; bool PasswordIsDefined;
UString Password; UString Password;
@ -28,17 +19,17 @@ public:
: PasswordIsDefined(false) { } : PasswordIsDefined(false) { }
}; };
STDMETHODIMP YCArchiveOpenCallback::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */) Z7_COM7F_IMF(YCArchiveOpenCallback::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */))
{ {
return S_OK; return S_OK;
} }
STDMETHODIMP YCArchiveOpenCallback::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */) Z7_COM7F_IMF(YCArchiveOpenCallback::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */))
{ {
return S_OK; return S_OK;
} }
STDMETHODIMP YCArchiveOpenCallback::CryptoGetTextPassword(BSTR *password) Z7_COM7F_IMF(YCArchiveOpenCallback::CryptoGetTextPassword(BSTR *password))
{ {
if (!PasswordIsDefined) { if (!PasswordIsDefined) {
// You can ask real password here from user // You can ask real password here from user

View File

@ -1,33 +1,15 @@
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD DEPENDPATH += $$PWD
win32 {
exists (../compressed_archive/lib7zip) { exists (../compressed_archive/lib7zip) {
message(Using 7zip) message(Using 7zip)
} else { } else {
error(You\'ll need 7zip source code to compile YACReader. \ error(You\'ll need 7zip source code to compile YACReader. \
Please check the compressed_archive folder for further instructions.) Please check the compressed_archive folder for further instructions.)
} }
}
unix {
exists (../compressed_archive/libp7zip) {
message(Found p7zip source code...)
#this is probably only needed in macos
system(patch -N -p0 -i libp7zip.patch)
} else {
error(You\'ll need 7zip source code to compile YACReader. \
Please check the compressed_archive folder for further instructions.)
}
}
win32 {
INCLUDEPATH += \ INCLUDEPATH += \
$$PWD/lib7zip/myWindows \
$$PWD/lib7zip/CPP \ $$PWD/lib7zip/CPP \
$$PWD/lib7zip/include_windows \
DEFINES += _UNICODE _WIN32
SOURCES += \ SOURCES += \
$$PWD/compressed_archive.cpp \ $$PWD/compressed_archive.cpp \
@ -37,26 +19,31 @@ SOURCES += \
$$PWD/lib7zip/CPP/Common/IntToString.cpp \ $$PWD/lib7zip/CPP/Common/IntToString.cpp \
$$PWD/lib7zip/CPP/Common/MyString.cpp \ $$PWD/lib7zip/CPP/Common/MyString.cpp \
$$PWD/lib7zip/CPP/Common/MyVector.cpp \ $$PWD/lib7zip/CPP/Common/MyVector.cpp \
$$PWD/lib7zip/CPP/Common/StringConvert.cpp \
$$PWD/lib7zip/CPP/Common/Wildcard.cpp \ $$PWD/lib7zip/CPP/Common/Wildcard.cpp \
$$PWD/lib7zip/CPP/7zip/Common/FileStreams.cpp \ $$PWD/lib7zip/CPP/7zip/Common/FileStreams.cpp \
$$PWD/lib7zip/CPP/7zip/Common/StreamUtils.cpp \
$$PWD/lib7zip/C/Alloc.c \ $$PWD/lib7zip/C/Alloc.c \
$$PWD/lib7zip/CPP/7zip/Common/StreamObjects.cpp $$PWD/lib7zip/CPP/7zip/Common/StreamObjects.cpp
unix{
SOURCES += \
$$PWD/lib7zip/CPP/Common/NewHandler.cpp \
$$PWD/lib7zip/CPP/Windows/DLL.cpp \
$$PWD/lib7zip/CPP/Windows/FileDir.cpp \
$$PWD/lib7zip/CPP/Windows/FileFind.cpp \
$$PWD/lib7zip/CPP/Windows/FileName.cpp \
$$PWD/lib7zip/CPP/Windows/TimeUtils.cpp \
$$PWD/lib7zip/CPP/Common/UTFConvert.cpp \
$$PWD/lib7zip/CPP/Common/MyWindows.cpp \
$$PWD/lib7zip/CPP/Common/StringConvert.cpp \
}
HEADERS += \ HEADERS += \
$$PWD/lib7zip/CPP/Common/Common.h \ $$PWD/lib7zip/CPP/Common/Common.h \
$$PWD/compressed_archive.h \ $$PWD/compressed_archive.h \
$$PWD/extract_delegate.h \ $$PWD/extract_delegate.h \
$$PWD/7z_includes.h \ $$PWD/7z_includes.h \
$$PWD/open_callbacks.h \ $$PWD/open_callbacks.h \
$$PWD/extract_callbacks.h $$PWD/extract_callbacks.h \
}
!win32 {
CONFIG += precompile_header
PRECOMPILED_HEADER = $$PWD/7z_precompiled_header.h
}
macx{ macx{
LIBS += -framework IOKit -framework CoreFoundation LIBS += -framework IOKit -framework CoreFoundation
@ -73,31 +60,3 @@ DEFINES += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE \
_7ZIP_LARGE_PAGES \ _7ZIP_LARGE_PAGES \
UNICODE _UNICODE UNIX_USE_WIN_FILE UNICODE _UNICODE UNIX_USE_WIN_FILE
} }
!win32 {
INCLUDEPATH += $$PWD/libp7zip/CPP/myWindows/ \
$$PWD/libp7zip/CPP/ \
$$PWD/libp7zip/CPP/include_windows/
SOURCES += \
$$PWD/compressed_archive.cpp \
$$PWD/libp7zip/CPP/Windows/PropVariant.cpp \
$$PWD/libp7zip/CPP/Windows/PropVariantConv.cpp \
$$PWD/libp7zip/CPP/Windows/FileIO.cpp \
$$PWD/libp7zip/CPP/Windows/FileFind.cpp \
$$PWD/libp7zip/CPP/Common/IntToString.cpp \
$$PWD/libp7zip/CPP/Common/MyString.cpp \
$$PWD/libp7zip/CPP/Common/MyVector.cpp \
$$PWD/libp7zip/CPP/Common/StringConvert.cpp \
$$PWD/libp7zip/CPP/Common/Wildcard.cpp \
$$PWD/libp7zip/CPP/7zip/Common/FileStreams.cpp \
$$PWD/libp7zip/CPP/7zip/Common/StreamUtils.cpp \
$$PWD/libp7zip/C/Alloc.c \
$$PWD/libp7zip/CPP/7zip/Common/StreamObjects.cpp \
$$PWD/libp7zip/CPP/myWindows/wine_date_and_time.cpp \
$$PWD/libp7zip/CPP/Common/MyWindows.cpp
HEADERS += \
$$PWD/compressed_archive.h \
$$PWD/7z_includes.h
}

1
dependencies/7zip/linux/TODO.txt vendored Normal file
View File

@ -0,0 +1 @@
Get 7z.so prebuilt binaires for 7zip 23.01 using Format7zF bundle with asm support.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1,3 @@
p7zip 16.02 built from the orignal sources using makefile.macosx_llvm_64bits 7zip 23.01 built from the original sources using the Format7zF bundle
TODO: try to get the optimized version of 7z.so by using the custom makefiles.

BIN
dependencies/7zip/macx/arm64/7z.so vendored Executable file

Binary file not shown.

BIN
dependencies/7zip/macx/x86_64/7z.so vendored Executable file

Binary file not shown.

View File

@ -1 +1 @@
7zip 18.05 dlls from the windows installers. 7zip 23.01 dlls from the windows installers.

Binary file not shown.

Binary file not shown.

View File

@ -19,31 +19,31 @@
"x": 80, "x": 80,
"y": 90, "y": 90,
"type": "file", "type": "file",
"path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-Intel #QT_VERSION#/YACReader.app" "path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-#ARCH_NAME# #QT_VERSION#/YACReader.app"
}, },
{ {
"x": 235, "x": 235,
"y": 90, "y": 90,
"type": "file", "type": "file",
"path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-Intel #QT_VERSION#/YACReaderLibrary.app" "path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-#ARCH_NAME# #QT_VERSION#/YACReaderLibrary.app"
}, },
{ {
"x": 470, "x": 470,
"y": 295, "y": 295,
"type": "file", "type": "file",
"path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-Intel #QT_VERSION#/YACReaderLibraryServer" "path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-#ARCH_NAME# #QT_VERSION#/YACReaderLibraryServer"
}, },
{ {
"x": 120, "x": 120,
"y": 295, "y": 295,
"type": "file", "type": "file",
"path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-Intel #QT_VERSION#/README.md" "path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-#ARCH_NAME# #QT_VERSION#/README.md"
}, },
{ {
"x": 290, "x": 290,
"y": 295, "y": 295,
"type": "file", "type": "file",
"path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-Intel #QT_VERSION#/COPYING.txt" "path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-#ARCH_NAME# #QT_VERSION#/COPYING.txt"
} }
] ]
} }