From 1903b6753f0ab356b7b6d25ccdd6e273328d19d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Tue, 18 Sep 2018 18:48:57 +0200 Subject: [PATCH] Update compressed_archive to support the latest version of 7zip 18.05 p7zip has been abandoned and the latest version available is 16.02. --- compressed_archive/7z_includes.h | 58 ++-- compressed_archive/README_7zip.txt | 14 +- compressed_archive/compressed_archive.cpp | 63 +++-- compressed_archive/compressed_archive.h | 18 +- compressed_archive/extract_callbacks.h | 308 +++++++++++----------- compressed_archive/libp7zip.patch | 16 +- compressed_archive/open_callbacks.h | 12 +- compressed_archive/wrapper.pri | 111 +++----- config.pri | 10 +- 9 files changed, 303 insertions(+), 307 deletions(-) diff --git a/compressed_archive/7z_includes.h b/compressed_archive/7z_includes.h index 41548046..ff39451d 100644 --- a/compressed_archive/7z_includes.h +++ b/compressed_archive/7z_includes.h @@ -3,6 +3,16 @@ //WIN includes #ifdef Q_OS_WIN +extern "C" +{ +#include "lib7zip/C/Alloc.h" +#include "lib7zip/C/7zTypes.h" +} + +#include "lib7zip/CPP/Common/Common.h" +#include "lib7zip/CPP/Common/MyWindows.h" + + #include "lib7zip/CPP/Common/StringConvert.h" #include "lib7zip/CPP/Common/MyInitGuid.h" #include "lib7zip/CPP/Common/MyCom.h" @@ -14,52 +24,56 @@ #include "lib7zip/CPP/7zip/IPassword.h" #include "lib7zip/CPP/7zip/MyVersion.h" -#include "lib7zip/C/Types.h" - #include "lib7zip/CPP/Windows/PropVariant.h" -#include "lib7zip/CPP/Windows/PropVariantConversions.h" +#include "lib7zip/CPP/Windows/PropVariantConv.h" #include "lib7zip/CPP/7zip/Common/StreamObjects.h" #include "lib7zip/CPP/7zip/Common/StreamUtils.h" -extern "C" -{ -#include "lib7zip/C/Alloc.h" -} #else //POSIX includes -#include "libp7zip/CPP/myWindows/myPrivate.h" -#include "libp7zip/CPP/myWindows/config.h" -#include "libp7zip/CPP/Common/MyGuidDef.h" +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/Common/MyInitGuid.h" -#include "libp7zip/CPP/Common/MyCom.h" -#include "libp7zip/CPP/7zip/Common/FileStreams.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/C/Types.h" - -#include "libp7zip/CPP/Windows/Defs.h" #include "libp7zip/CPP/Windows/PropVariant.h" -#include "libp7zip/CPP/Windows/PropVariantConversions.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" -extern "C" -{ -#include "libp7zip/C/Alloc.h" -} + #endif #endif // _7Z_INCLUDES_H diff --git a/compressed_archive/README_7zip.txt b/compressed_archive/README_7zip.txt index 63114741..4ab47185 100644 --- a/compressed_archive/README_7zip.txt +++ b/compressed_archive/README_7zip.txt @@ -4,16 +4,6 @@ you need to download de source code of 7zip (Windows) or p7zip (Linux/MacOSX). Please extract it and rename the folder to lib7zip (Windows) or libp7zip (Linux/MacOSX), then copy it to $YACREADER_SRC/compressed_archive/ (this folder). -YACReader is compiled using 7zip/p7zip 9.20.1 and will not work with newer versions. +YACReader is compiled using 7zip 18.05 and p7zip 16.02. -On Linux/Unix this means your YACReader installation will stop working if you -update your installation of p7zip to a newer version. If you wish to keep using -p7zip with YACReader, you can copy 7z.so and Codecs/Rar29.so from p7zip 9.20.1 -to "/usr/lib/yacreader/". YACReader will then detect these files and use -them instead of the system provided p7zip files which allows you to keep both -YACReader and an up to date p7zip installation. - -Please keep in mind this is only a workaround that is provided for backwards -compatibility and not intended as a long time solution. -It is recommended that you switch to unarr as a decompression backend instead -(see README.txt in compressed_archive/unarr). +7zip is the recommended library to use is you want support for 7zip files and rar5. diff --git a/compressed_archive/compressed_archive.cpp b/compressed_archive/compressed_archive.cpp index 11b3056a..91e4bf6b 100644 --- a/compressed_archive/compressed_archive.cpp +++ b/compressed_archive/compressed_archive.cpp @@ -1,3 +1,7 @@ +#ifdef Q_OS_UNIX +#include "libp7zip/CPP/Common/MyInitGuid.h" +#endif + #include "compressed_archive.h" #include "extract_delegate.h" @@ -9,12 +13,28 @@ #include "open_callbacks.h" #include "extract_callbacks.h" +#include "7z_includes.h" + +#ifdef Q_OS_WIN + #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 *GetMethodPropertyFunc)(quint32 index, PROPID propID, PROPVARIANT *value); +typedef quint32 (_MY_WINAPI *GetNumberOfMethodsFunc)(quint32 *numMethods); +typedef quint32 (_MY_WINAPI *GetNumberOfFormatsFunc)(quint32 *numFormats); +typedef quint32 (_MY_WINAPI *GetHandlerPropertyFunc)(PROPID propID, PROPVARIANT *value); +typedef quint32 (_MY_WINAPI *GetHandlerPropertyFunc2)(quint32 index, PROPID propID, PROPVARIANT *value); +typedef quint32 (_MY_WINAPI *SetLargePageModeFunc)(); //DEFINE_GUID(CLSID_CFormat7z,0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00); //DEFINE_GUID(IArchiveKK,0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x06, 0x00, 0x60, 0x00, 0x00); DEFINE_GUID(CLSID_CFormat7z, 0x23170f69, 0x40c1, 0x278a, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00); DEFINE_GUID(CLSID_CFormatRar, 0x23170f69, 0x40c1, 0x278a, 0x10, 0x00, 0x00, 0x01, 0x10, 0x03, 0x00, 0x00); +DEFINE_GUID(CLSID_CFormatRar5, 0X23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xCC, 0x00, 0x00); DEFINE_GUID(CLSID_CFormatZip, 0x23170f69, 0x40c1, 0x278a, 0x10, 0x00, 0x00, 0x01, 0x10, 0x01, 0x00, 0x00); DEFINE_GUID(CLSID_CFormatTar, 0x23170f69, 0x40c1, 0x278a, 0x10, 0x00, 0x00, 0x01, 0x10, 0xee, 0x00, 0x00); DEFINE_GUID(CLSID_CFormatArj, 0x23170f69, 0x40c1, 0x278a, 0x10, 0x00, 0x00, 0x01, 0x10, 0x04, 0x00, 0x00); @@ -37,21 +57,21 @@ DEFINE_GUID(CLSID_CFormatWim, 0x23170f69, 0x40c1, 0x278a, 0x10, 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}; +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 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_ISetCompressCodecsInfo, 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 +/*#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 +#endif*/ struct SevenZipInterface { CreateObjectFunc createObjectFunc; @@ -101,7 +121,7 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent) CInFileStream *fileSpec = new CInFileStream; CMyComPtr file = fileSpec; - CArchiveOpenCallback *openCallbackSpec = new CArchiveOpenCallback; + YCArchiveOpenCallback *openCallbackSpec = new YCArchiveOpenCallback; CMyComPtr openCallback = openCallbackSpec; openCallbackSpec->PasswordIsDefined = false; // openCallbackSpec->PasswordIsDefined = true; @@ -151,7 +171,7 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent) #else if (memcmp(magicNumber,rar,6) == 0) if (memcmp(magicNumber,rar5,7) == 0) - return; + i=5; else i=0; else if (memcmp(magicNumber,zip,2)==0) @@ -218,11 +238,16 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent) } else { - if (memcmp(magicNumber,rar5,7) == 0) - return;//we don't support rar5 - + //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(&CLSID_CFormatRar, &IID_InArchive, (void **)&szInterface->archive) != S_OK) + if (szInterface->createObjectFunc(&clsidRar, &IID_InArchive, (void **)&szInterface->archive) != S_OK) { qDebug() << "Error creating rar archive :" + filePath; return; @@ -230,7 +255,7 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent) CMyComPtr codecsInfo; - if (szInterface->archive->QueryInterface(IID_ISetCompressCodecsInfo,(void **)&codecsInfo) != S_OK) + if (szInterface->archive->QueryInterface(IID_ISetCompressCodecsInfoX,(void **)&codecsInfo) != S_OK) { qDebug() << "Error getting rar codec :" + filePath; return; @@ -296,22 +321,22 @@ bool CompressedArchive::loadFunctions() { #if defined Q_OS_UNIX #if defined Q_OS_MAC - rarLib = new QLibrary(QCoreApplication::applicationDirPath()+"/utils/Codecs/Rar29"); + 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/Rar29.so"); + QFileInfo rarCodec(QString(LIBDIR)+"/yacreader/Codecs/Rar.so"); if (rarCodec.exists()) { rarLib = new QLibrary(rarCodec.absoluteFilePath()); } else { - rarLib = new QLibrary(QString(LIBDIR)+"/p7zip/Codecs/Rar29.so"); + rarLib = new QLibrary(QString(LIBDIR)+"/p7zip/Codecs/Rar.so"); } #endif if(!rarLib->load()) { - qDebug() << "Error Loading Rar29.so : " + rarLib->errorString() << endl; + qDebug() << "Error Loading Rar.so : " + rarLib->errorString() << endl; QCoreApplication::exit(700); //TODO yacreader_global can't be used here, it is GUI dependant, YACReader::SevenZNotFound return false; } @@ -387,7 +412,7 @@ void CompressedArchive::setupFilesNames() if(!isDir) { szInterface->archive->GetProperty(i, kpidPath, &prop); - UString s = ConvertPropVariantToString(prop); + UString s = prop.bstrVal; const wchar_t * chars = s.operator const wchar_t *(); files.append(QString::fromWCharArray(chars)); offsets.append(i); @@ -440,7 +465,7 @@ int CompressedArchive::getNumEntries() QList CompressedArchive::getAllData(const QVector & indexes, ExtractDelegate * delegate) { - CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback(indexesToPages, true, delegate); + YCArchiveExtractCallback *extractCallbackSpec = new YCArchiveExtractCallback(indexesToPages, true, delegate); CMyComPtr extractCallback(extractCallbackSpec); extractCallbackSpec->Init(szInterface->archive, L""); // second parameter is output folder path extractCallbackSpec->PasswordIsDefined = false; @@ -464,7 +489,7 @@ QByteArray CompressedArchive::getRawDataAtIndex(int index) { if(index>=0 && index < getNumFiles()) { - CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback(indexesToPages); + YCArchiveExtractCallback *extractCallbackSpec = new YCArchiveExtractCallback(indexesToPages); CMyComPtr extractCallback(extractCallbackSpec); extractCallbackSpec->Init(szInterface->archive, L""); // second parameter is output folder path extractCallbackSpec->PasswordIsDefined = false; @@ -489,7 +514,7 @@ QByteArray CompressedArchive::getRawDataAtIndex(int index) #ifdef Q_OS_UNIX -STDMETHODIMP CompressedArchive::GetNumberOfMethods(UInt32 *numMethods) +STDMETHODIMP CompressedArchive::GetNumMethods(UInt32 *numMethods) { return szInterface->getNumberOfMethodsFuncRar(numMethods); } diff --git a/compressed_archive/compressed_archive.h b/compressed_archive/compressed_archive.h index 0360a5dd..07017107 100644 --- a/compressed_archive/compressed_archive.h +++ b/compressed_archive/compressed_archive.h @@ -8,23 +8,9 @@ #include "libp7zip/CPP/Common/MyCom.h" #endif + class ExtractDelegate; -#ifdef Q_OS_WIN - #include "7z_includes.h" - #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 *GetMethodPropertyFunc)(quint32 index, PROPID propID, PROPVARIANT *value); -typedef quint32 (_MY_WINAPI *GetNumberOfMethodsFunc)(quint32 *numMethods); -typedef quint32 (_MY_WINAPI *GetNumberOfFormatsFunc)(quint32 *numFormats); -typedef quint32 (_MY_WINAPI *GetHandlerPropertyFunc)(PROPID propID, PROPVARIANT *value); -typedef quint32 (_MY_WINAPI *GetHandlerPropertyFunc2)(quint32 index, PROPID propID, PROPVARIANT *value); -typedef quint32 (_MY_WINAPI *SetLargePageModeFunc)(); - class QLibrary; #include #include @@ -48,7 +34,7 @@ public: #ifdef Q_OS_UNIX MY_UNKNOWN_IMP - STDMETHOD(GetNumberOfMethods)(UInt32 *numMethods); + 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); diff --git a/compressed_archive/extract_callbacks.h b/compressed_archive/extract_callbacks.h index cbed4e5b..07591e80 100644 --- a/compressed_archive/extract_callbacks.h +++ b/compressed_archive/extract_callbacks.h @@ -28,11 +28,11 @@ static HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propI NCOM::CPropVariant prop; RINOK(archive->GetProperty(index, propID, &prop)); if (prop.vt == VT_BOOL) - result = VARIANT_BOOLToBool(prop.boolVal); + result = VARIANT_BOOLToBool(prop.boolVal); else if (prop.vt == VT_EMPTY) - result = false; + result = false; else - return E_FAIL; + return E_FAIL; return S_OK; } static HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result) @@ -40,7 +40,7 @@ static HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &resu return IsArchiveItemProp(archive, index, kpidIsDir, result); } -class CArchiveExtractCallback: +class YCArchiveExtractCallback: public IArchiveExtractCallback, public ICryptoGetTextPassword, public CMyUnknownImp @@ -71,11 +71,11 @@ private: UInt32 _index; struct CProcessedFileInfo { - FILETIME MTime; - UInt32 Attrib; - bool isDir; - bool AttribDefined; - bool MTimeDefined; + FILETIME MTime; + UInt32 Attrib; + bool isDir; + bool AttribDefined; + bool MTimeDefined; } _processedFileInfo; COutFileStream *_outFileStreamSpec; @@ -92,29 +92,29 @@ public: UInt64 newFileSize; QMap indexesToPages; - CArchiveExtractCallback(const QMap & indexesToPages ,bool c = false,ExtractDelegate * d = 0) : PasswordIsDefined(false),all(c),delegate(d),indexesToPages(indexesToPages) {} - ~CArchiveExtractCallback() {MidFree(data);} + YCArchiveExtractCallback(const QMap & indexesToPages ,bool c = false,ExtractDelegate * d = 0) : PasswordIsDefined(false),all(c),delegate(d),indexesToPages(indexesToPages) {} + ~YCArchiveExtractCallback() {MidFree(data);} }; -void CArchiveExtractCallback::Init(IInArchive *archiveHandler, const UString &directoryPath) +void YCArchiveExtractCallback::Init(IInArchive *archiveHandler, const UString &directoryPath) { NumErrors = 0; _archiveHandler = archiveHandler; - directoryPath;//unused + directoryPath;//unused } -STDMETHODIMP CArchiveExtractCallback::SetTotal(UInt64 /* size */) +STDMETHODIMP YCArchiveExtractCallback::SetTotal(UInt64 /* size */) { return S_OK; } -STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 * /* completeValue */) +STDMETHODIMP YCArchiveExtractCallback::SetCompleted(const UInt64 * /* completeValue */) { return S_OK; } -STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, - ISequentialOutStream **outStream, Int32 askExtractMode) +STDMETHODIMP YCArchiveExtractCallback::GetStream(UInt32 index, + ISequentialOutStream **outStream, Int32 askExtractMode) { *outStream = 0; _outFileStream.Release(); @@ -125,83 +125,83 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, _index = indexesToPages.value(index); { - // Get Name - NCOM::CPropVariant prop; - RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop)); - - UString fullPath; - if (prop.vt == VT_EMPTY) - fullPath = kEmptyFileAlias; - else - { - if (prop.vt != VT_BSTR) - return E_FAIL; - fullPath = prop.bstrVal; - } - _filePath = fullPath; + // Get Name + NCOM::CPropVariant prop; + RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop)); + + UString fullPath; + if (prop.vt == VT_EMPTY) + fullPath = kEmptyFileAlias; + else + { + if (prop.vt != VT_BSTR) + return E_FAIL; + fullPath = prop.bstrVal; + } + _filePath = fullPath; } - askExtractMode;//unused + askExtractMode;//unused //if (askExtractMode != NArchive::NExtract::NAskMode::kExtract) - //return S_OK; + //return S_OK; { - // Get Attrib - NCOM::CPropVariant prop; - RINOK(_archiveHandler->GetProperty(index, kpidAttrib, &prop)); - if (prop.vt == VT_EMPTY) - { - _processedFileInfo.Attrib = 0; - _processedFileInfo.AttribDefined = false; - } - else - { - if (prop.vt != VT_UI4) - return E_FAIL; - _processedFileInfo.Attrib = prop.ulVal; - _processedFileInfo.AttribDefined = true; - } + // Get Attrib + NCOM::CPropVariant prop; + RINOK(_archiveHandler->GetProperty(index, kpidAttrib, &prop)); + if (prop.vt == VT_EMPTY) + { + _processedFileInfo.Attrib = 0; + _processedFileInfo.AttribDefined = false; + } + else + { + if (prop.vt != VT_UI4) + return E_FAIL; + _processedFileInfo.Attrib = prop.ulVal; + _processedFileInfo.AttribDefined = true; + } } RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.isDir)); { - // Get Modified Time - NCOM::CPropVariant prop; - RINOK(_archiveHandler->GetProperty(index, kpidMTime, &prop)); - _processedFileInfo.MTimeDefined = false; - switch(prop.vt) - { - case VT_EMPTY: - // _processedFileInfo.MTime = _utcMTimeDefault; - break; - case VT_FILETIME: - _processedFileInfo.MTime = prop.filetime; - _processedFileInfo.MTimeDefined = true; - break; - default: - return E_FAIL; - } + // Get Modified Time + NCOM::CPropVariant prop; + RINOK(_archiveHandler->GetProperty(index, kpidMTime, &prop)); + _processedFileInfo.MTimeDefined = false; + switch(prop.vt) + { + case VT_EMPTY: + // _processedFileInfo.MTime = _utcMTimeDefault; + break; + case VT_FILETIME: + _processedFileInfo.MTime = prop.filetime; + _processedFileInfo.MTimeDefined = true; + break; + default: + return E_FAIL; + } } - //se necesita conocer el tamaño del archivo para poder reservar suficiente memoria + //se necesita conocer el tama?o del archivo para poder reservar suficiente memoria bool newFileSizeDefined; { - // Get Size - NCOM::CPropVariant prop; - RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop)); - newFileSizeDefined = (prop.vt != VT_EMPTY); - if (newFileSizeDefined) - newFileSize = ConvertPropVariantToUInt64(prop); + // Get Size + NCOM::CPropVariant prop; + RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop)); + newFileSizeDefined = (prop.vt != VT_EMPTY); + if (newFileSizeDefined) + ConvertPropVariantToUInt64(prop, newFileSize); } - //No hay que crear ningún fichero, ni directorios intermedios + //No hay que crear ning?n fichero, ni directorios intermedios /*{ - // Create folders for file - int slashPos = _filePath.ReverseFind(WCHAR_PATH_SEPARATOR); - if (slashPos >= 0) - NFile::NDirectory::CreateComplexDirectory(_directoryPath + _filePath.Left(slashPos)); + // Create folders for file + int slashPos = _filePath.ReverseFind(WCHAR_PATH_SEPARATOR); + if (slashPos >= 0) + NFile::NDirectory::CreateComplexDirectory(_directoryPath + _filePath.Left(slashPos)); } UString fullProcessedPath = _directoryPath + _filePath; @@ -209,123 +209,123 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, */ if (_processedFileInfo.isDir) { - //NFile::NDirectory::CreateComplexDirectory(fullProcessedPath); + //NFile::NDirectory::CreateComplexDirectory(fullProcessedPath); } else { - /*NFile::NFind::CFileInfoW fi; - if (fi.Find(fullProcessedPath)) - { - if (!NFile::NDirectory::DeleteFileAlways(fullProcessedPath)) - { - qDebug() <<(UString(kCantDeleteOutputFile) + fullProcessedPath); - return E_ABORT; - } - }*/ - if(newFileSizeDefined) - { - CBufPtrSeqOutStream *outStreamSpec = new CBufPtrSeqOutStream; - CMyComPtr outStreamLocal(outStreamSpec); - data = (Byte *)MidAlloc(newFileSize); - outStreamSpec->Init(data, newFileSize); - *outStream = outStreamLocal.Detach(); - } - else - { + /*NFile::NFind::CFileInfoW fi; + if (fi.Find(fullProcessedPath)) + { + if (!NFile::NDirectory::DeleteFileAlways(fullProcessedPath)) + { + qDebug() <<(UString(kCantDeleteOutputFile) + fullProcessedPath); + return E_ABORT; + } + }*/ + if(newFileSizeDefined) + { + CBufPtrSeqOutStream *outStreamSpec = new CBufPtrSeqOutStream; + CMyComPtr outStreamLocal(outStreamSpec); + data = (Byte *)MidAlloc(newFileSize); + outStreamSpec->Init(data, newFileSize); + *outStream = outStreamLocal.Detach(); + } + else + { - } + } } return S_OK; } -STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode) +STDMETHODIMP YCArchiveExtractCallback::PrepareOperation(Int32 askExtractMode) { _extractMode = false; switch (askExtractMode) { - case NArchive::NExtract::NAskMode::kExtract: _extractMode = true; break; + case NArchive::NExtract::NAskMode::kExtract: _extractMode = true; break; }; /* switch (askExtractMode) { - case NArchive::NExtract::NAskMode::kExtract: qDebug() << (kExtractingString); break; - case NArchive::NExtract::NAskMode::kTest: qDebug() <<(kTestingString); break; - case NArchive::NExtract::NAskMode::kSkip: qDebug() <<(kSkippingString); break; + case NArchive::NExtract::NAskMode::kExtract: qDebug() << (kExtractingString); break; + case NArchive::NExtract::NAskMode::kTest: qDebug() <<(kTestingString); break; + case NArchive::NExtract::NAskMode::kSkip: qDebug() <<(kSkippingString); break; };*/ //qDebug() << _filePath; return S_OK; } -STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult) +STDMETHODIMP YCArchiveExtractCallback::SetOperationResult(Int32 operationResult) { switch(operationResult) { - case NArchive::NExtract::NOperationResult::kOK: - if(all && !_processedFileInfo.isDir) - { - QByteArray rawData((char *)data,newFileSize); - MidFree(data); - data = 0; - if(delegate != 0) - delegate->fileExtracted(_index,rawData); - else - { - allFiles.append(rawData); - } - } - break; - default: - { - NumErrors++; - qDebug() << " "; - switch(operationResult) - { - case NArchive::NExtract::NOperationResult::kUnSupportedMethod: - if(delegate != 0) - delegate->unknownError(_index); - qDebug() << kUnsupportedMethod; - break; - case NArchive::NExtract::NOperationResult::kCRCError: - if(delegate != 0) - delegate->crcError(_index); - qDebug() << kCRCFailed; - break; - case NArchive::NExtract::NOperationResult::kDataError: - if(delegate != 0) - delegate->unknownError(_index); - qDebug() << kDataError; - break; - default: - if(delegate != 0) - delegate->unknownError(_index); - qDebug() << kUnknownError; - } - } + case NArchive::NExtract::NOperationResult::kOK: + if(all && !_processedFileInfo.isDir) + { + QByteArray rawData((char *)data,newFileSize); + MidFree(data); + data = 0; + if(delegate != 0) + delegate->fileExtracted(_index,rawData); + else + { + allFiles.append(rawData); + } + } + break; + default: + { + NumErrors++; + qDebug() << " "; + switch(operationResult) + { + case NArchive::NExtract::NOperationResult::kUnsupportedMethod: + if(delegate != 0) + delegate->unknownError(_index); + qDebug() << kUnsupportedMethod; + break; + case NArchive::NExtract::NOperationResult::kCRCError: + if(delegate != 0) + delegate->crcError(_index); + qDebug() << kCRCFailed; + break; + case NArchive::NExtract::NOperationResult::kDataError: + if(delegate != 0) + delegate->unknownError(_index); + qDebug() << kDataError; + break; + default: + if(delegate != 0) + delegate->unknownError(_index); + qDebug() << kUnknownError; + } + } } /* if (_outFileStream != NULL) { - if (_processedFileInfo.MTimeDefined) - _outFileStreamSpec->SetMTime(&_processedFileInfo.MTime); - RINOK(_outFileStreamSpec->Close()); + if (_processedFileInfo.MTimeDefined) + _outFileStreamSpec->SetMTime(&_processedFileInfo.MTime); + RINOK(_outFileStreamSpec->Close()); } _outFileStream.Release(); if (_extractMode && _processedFileInfo.AttribDefined) - NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attrib);*/ + NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attrib);*/ //qDebug() << endl; return S_OK; } -STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password) +STDMETHODIMP YCArchiveExtractCallback::CryptoGetTextPassword(BSTR *password) { if (!PasswordIsDefined) { - // You can ask real password here from user - // Password = GetPassword(OutStream); - // PasswordIsDefined = true; - qDebug() << "Password is not defined" << endl; - return E_ABORT; + // You can ask real password here from user + // Password = GetPassword(OutStream); + // PasswordIsDefined = true; + qDebug() << "Password is not defined" << endl; + return E_ABORT; } return StringToBstr(Password, password); } diff --git a/compressed_archive/libp7zip.patch b/compressed_archive/libp7zip.patch index 522c1202..7e226f4f 100644 --- a/compressed_archive/libp7zip.patch +++ b/compressed_archive/libp7zip.patch @@ -1,11 +1,11 @@ ---- libp7zip/CPP/myWindows/StdAfx.h 2014-06-06 23:52:13.397311952 +0200 -+++ libp7zip/CPP/myWindows/StdAfx.h 2014-06-06 23:53:20.353981756 +0200 -@@ -114,7 +114,7 @@ +--- libp7zip/CPP/include_windows/windows.h 2018-09-18 17:17:26.000000000 +0200 +--- libp7zip/CPP/include_windows/windows.h 2018-09-18 17:17:24.000000000 +0200 +@@ -36,7 +36,7 @@ + #define WINAPI - #if defined( __x86_64__ ) + #undef BOOL +-typedef int BOOL; ++typedef signed char BOOL; --#define _WIN64 1 -+//#define _WIN64 1 - - #endif + #define CREATE_NEW 1 diff --git a/compressed_archive/open_callbacks.h b/compressed_archive/open_callbacks.h index e5d1ef43..2ba38319 100644 --- a/compressed_archive/open_callbacks.h +++ b/compressed_archive/open_callbacks.h @@ -7,7 +7,7 @@ // Archive Open callback class -class CArchiveOpenCallback: +class YCArchiveOpenCallback: public IArchiveOpenCallback, public ICryptoGetTextPassword, public CMyUnknownImp @@ -23,20 +23,20 @@ public: bool PasswordIsDefined; UString Password; - CArchiveOpenCallback() : PasswordIsDefined(false) {} + YCArchiveOpenCallback() : PasswordIsDefined(false) {} }; -STDMETHODIMP CArchiveOpenCallback::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */) +STDMETHODIMP YCArchiveOpenCallback::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */) { return S_OK; } -STDMETHODIMP CArchiveOpenCallback::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */) +STDMETHODIMP YCArchiveOpenCallback::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */) { return S_OK; } -STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR *password) +STDMETHODIMP YCArchiveOpenCallback::CryptoGetTextPassword(BSTR *password) { if (!PasswordIsDefined) { @@ -51,4 +51,4 @@ STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR *password) -#endif \ No newline at end of file +#endif diff --git a/compressed_archive/wrapper.pri b/compressed_archive/wrapper.pri index fde3b240..863fc4c1 100644 --- a/compressed_archive/wrapper.pri +++ b/compressed_archive/wrapper.pri @@ -11,6 +11,7 @@ win32 { 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. \ @@ -18,110 +19,82 @@ exists (../compressed_archive/libp7zip) { } } -CONFIG += precompile_header - -win32 {PRECOMPILED_HEADER = $$PWD/StdAfx.h} -!win32 {PRECOMPILED_HEADER = $$PWD/libp7zip/CPP/myWindows/StdAfx.h} - win32 { -INCLUDEPATH += $$PWD/lib7zip/CPP/ +INCLUDEPATH += \ + $$PWD/lib7zip/myWindows \ + $$PWD/lib7zip/CPP \ + $$PWD/lib7zip/include_windows \ -DEFINES += _UNICODE _WIN32 +DEFINES += _UNICODE _WIN32 -SOURCES += $$PWD/compressed_archive.cpp \ +SOURCES += \ + $$PWD/compressed_archive.cpp \ $$PWD/lib7zip/CPP/Windows/FileIO.cpp \ $$PWD/lib7zip/CPP/Windows/PropVariant.cpp \ - $$PWD/lib7zip/CPP/Windows/PropVariantConversions.cpp \ + $$PWD/lib7zip/CPP/Windows/PropVariantConv.cpp \ $$PWD/lib7zip/CPP/Common/IntToString.cpp \ $$PWD/lib7zip/CPP/Common/MyString.cpp \ $$PWD/lib7zip/CPP/Common/MyVector.cpp \ $$PWD/lib7zip/CPP/Common/StringConvert.cpp \ $$PWD/lib7zip/CPP/Common/Wildcard.cpp \ $$PWD/lib7zip/CPP/7zip/Common/FileStreams.cpp \ - $$PWD/lib7zip/CPP/7zip/Common/StreamUtils.cpp \ - $$PWD/lib7zip/C/Alloc.c \ - $$PWD/lib7zip/CPP/7zip/Common/StreamObjects.cpp + $$PWD/lib7zip/CPP/7zip/Common/StreamUtils.cpp \ + $$PWD/lib7zip/C/Alloc.c \ + $$PWD/lib7zip/CPP/7zip/Common/StreamObjects.cpp -HEADERS += $$PWD/compressed_archive.h \ +HEADERS += \ + $$PWD/lib7zip/CPP/Common/Common.h \ + $$PWD/compressed_archive.h \ $$PWD/extract_delegate.h \ $$PWD/7z_includes.h \ - $$PWD/open_callbacks.h \ - $$PWD/extract_callbacks.h\ - $$PWD/lib7zip/CPP/Windows/FileIO.h \ - $$PWD/lib7zip/CPP/Windows/PropVariant.h \ - $$PWD/lib7zip/CPP/Windows/PropVariantConversions.h \ - $$PWD/lib7zip/CPP/Common/IntToString.h \ - $$PWD/lib7zip/CPP/Common/MyString.h \ - $$PWD/lib7zip/CPP/Common/MyVector.h \ - $$PWD/lib7zip/CPP/Common/StringConvert.h \ - $$PWD/lib7zip/CPP/Common/Wildcard.h \ - $$PWD/lib7zip/CPP/7zip/Common/FileStreams.h \ - $$PWD/lib7zip/CPP/7zip/IStream.h \ - $$PWD/lib7zip/CPP/7zip/Common/StreamUtils.h \ - $$PWD/lib7zip/C/Alloc.h \ - $$PWD/lib7zip/CPP/7zip/Common/StreamObjects.h + $$PWD/open_callbacks.h \ + $$PWD/extract_callbacks.h +} + +!win32 { +CONFIG += precompile_header +PRECOMPILED_HEADER = $$PWD/7z_precompiled_header.h } macx{ LIBS += -framework IOKit -framework CoreFoundation -DEFINES += UNICODE _UNICODE _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE \ +DEFINES += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE \ NDEBUG _REENTRANT ENV_UNIX \ - _7ZIP_LARGE_PAGES ENV_MACOSX _TCHAR_DEFINED + _7ZIP_LARGE_PAGES ENV_MACOSX _TCHAR_DEFINED \ + UNICODE _UNICODE UNIX_USE_WIN_FILE } unix:!macx{ DEFINES += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE \ NDEBUG _REENTRANT ENV_UNIX \ - _7ZIP_LARGE_PAGES + _7ZIP_LARGE_PAGES } !win32 { -INCLUDEPATH += $$PWD/libp7zip/CPP/ \ - $$PWD/libp7zip/CPP/myWindows/ \ +INCLUDEPATH += $$PWD/libp7zip/CPP/myWindows/ \ + $$PWD/libp7zip/CPP/ \ $$PWD/libp7zip/CPP/include_windows/ - -SOURCES += $$PWD/compressed_archive.cpp \ + +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/Windows/PropVariant.cpp \ - $$PWD/libp7zip/CPP/Windows/PropVariantConversions.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 + $$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 \ - $$PWD/open_callbacks.h \ - $$PWD/extract_callbacks.h\ - $$PWD/libp7zip/CPP/include_windows/windows.h \ - $$PWD/libp7zip/CPP/include_windows/tchar.h \ - $$PWD/libp7zip/CPP/include_windows/basetyps.h \ - $$PWD/libp7zip/CPP/Windows/FileFind.h \ - $$PWD/libp7zip/CPP/Windows/FileIO.h \ - $$PWD/libp7zip/CPP/Windows/PropVariant.h \ - $$PWD/libp7zip/CPP/Windows/PropVariantConversions.h \ - $$PWD/libp7zip/CPP/Common/IntToString.h \ - $$PWD/libp7zip/CPP/Common/MyString.h \ - $$PWD/libp7zip/CPP/Common/MyVector.h \ - $$PWD/libp7zip/CPP/Common/StringConvert.h \ - $$PWD/libp7zip/CPP/Common/Wildcard.h \ - $$PWD/libp7zip/CPP/7zip/Common/FileStreams.h \ - $$PWD/libp7zip/CPP/7zip/IStream.h \ - $$PWD/libp7zip/CPP/7zip/Common/StreamUtils.h \ - $$PWD/libp7zip/C/Alloc.h \ - $$PWD/libp7zip/CPP/7zip/Common/StreamObjects.h \ - $$PWD/libp7zip/CPP/Common/MyWindows.h \ - $$PWD/libp7zip/CPP/7zip/ICoder.h \ -} - - - +HEADERS += \ + $$PWD/compressed_archive.h \ + $$PWD/7z_includes.h +} diff --git a/config.pri b/config.pri index b98dc094..7c144345 100644 --- a/config.pri +++ b/config.pri @@ -30,10 +30,18 @@ CONFIG(no_opengl) { } # default value for comic archive decompression backend -!CONFIG(unarr):!CONFIG(7zip) { +unix:!macx:!CONFIG(unarr):!CONFIG(7zip) { CONFIG += unarr } +win32:!CONFIG(unarr):!CONFIG(7zip) { + CONFIG += 7zip +} + +macx:!CONFIG(unarr):!CONFIG(7zip) { + CONFIG += 7zip +} + # default values for pdf render backend win32:!CONFIG(poppler):!CONFIG(pdfium):!CONFIG(no_pdf) { CONFIG += pdfium