mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04:00
Merge
This commit is contained in:
@ -4,21 +4,22 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include "extract_delegate.h"
|
||||
|
||||
extern"C" {
|
||||
#include <unarr.h>
|
||||
}
|
||||
|
||||
CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent) :
|
||||
QObject(parent),tools(true),valid(false),numFiles(0),ar(NULL),stream(NULL)
|
||||
{
|
||||
//open file
|
||||
stream = ar_open_file(filePath.toStdString().c_str());
|
||||
#ifdef Q_OS_WIN
|
||||
stream = ar_open_file_w((wchar_t *)filePath.utf16());
|
||||
#else
|
||||
stream = ar_open_file(filePath.toLocal8Bit().constData());
|
||||
#endif
|
||||
if (!stream)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//open archive
|
||||
ar = ar_open_rar_archive(stream);
|
||||
//TODO: build unarr with 7z support and test this!
|
||||
@ -30,9 +31,9 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//initial parse
|
||||
while (ar_parse_entry(ar))
|
||||
while (ar_parse_entry(ar))
|
||||
{
|
||||
//make sure we really got a file header
|
||||
if (ar_entry_get_size(ar) > 0)
|
||||
@ -43,7 +44,7 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent)
|
||||
}
|
||||
}
|
||||
if (!ar_at_eof(ar))
|
||||
{
|
||||
{
|
||||
//fail if the initial parse didn't reach EOF
|
||||
//this might be a bit too drastic
|
||||
qDebug() << "Error while parsing archive";
|
||||
@ -84,11 +85,11 @@ int CompressedArchive::getNumFiles()
|
||||
|
||||
void CompressedArchive::getAllData(const QVector<quint32> & indexes, ExtractDelegate * delegate)
|
||||
{
|
||||
if (indexes.isEmpty())
|
||||
if (indexes.isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
QByteArray buffer;
|
||||
|
||||
|
||||
int i=0;
|
||||
while (i < indexes.count())
|
||||
{
|
||||
@ -102,7 +103,7 @@ void CompressedArchive::getAllData(const QVector<quint32> & indexes, ExtractDele
|
||||
else
|
||||
{
|
||||
delegate->crcError(indexes.at(i)); //we could not extract it...
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -2,39 +2,46 @@ INCLUDEPATH += $$PWD
|
||||
DEPENDPATH += $$PWD
|
||||
|
||||
HEADERS += $$PWD/extract_delegate.h \
|
||||
$$PWD/compressed_archive.h \
|
||||
$$PWD/compressed_archive.h
|
||||
|
||||
SOURCES += $$PWD/compressed_archive.cpp \
|
||||
SOURCES += $$PWD/compressed_archive.cpp
|
||||
|
||||
unix:!macx:exists (/usr/include/unarr.h) {
|
||||
message(Using system provided unarr installation)
|
||||
LIBS+=-lunarr
|
||||
DEFINES+=use_unarr
|
||||
}
|
||||
else:macx:exists (../../dependencies/unarr/macx/libunarr.a) {
|
||||
message(Found prebuilt unarr library in dependencies directory.)
|
||||
INCLUDEPATH += $$PWD/../../dependencies/unarr/macx
|
||||
LIBS += -L$$PWD/../../dependencies/unarr/macx -lunarr -lz -lbz2
|
||||
DEFINES+=use_unarr
|
||||
}
|
||||
unix:!macx:packagesExist(libunarr) {
|
||||
message(Using system provided unarr installation)
|
||||
CONFIG += link_pkgconfig
|
||||
PKGCONFIG += libunarr
|
||||
DEFINES += use_unarr
|
||||
}
|
||||
|
||||
else:win32:exists (../../dependencies/unarr/win/unarr.h) {
|
||||
message(Found prebuilt unarr library in dependencies directory.)
|
||||
INCLUDEPATH += $$PWD/../../dependencies/unarr/win
|
||||
LIBS += -L../../dependencies/unarr/win/ -lunarr
|
||||
DEFINES+=use_unarr
|
||||
}
|
||||
else:macx:exists(../../dependencies/unarr/macx/libunarr.a) {
|
||||
message(Found prebuilt unarr library in dependencies directory.)
|
||||
INCLUDEPATH += $$PWD/../../dependencies/unarr/macx
|
||||
LIBS += -L$$PWD/../../dependencies/unarr/macx -lunarr -lz -lbz2
|
||||
DEFINES += use_unarr
|
||||
}
|
||||
|
||||
else:win32:exists(../../dependencies/unarr/win/unarr.h) {
|
||||
message(Found prebuilt unarr library in dependencies directory.)
|
||||
INCLUDEPATH += $$PWD/../../dependencies/unarr/win
|
||||
contains(QMAKE_TARGET.arch, x86_64): {
|
||||
LIBS += -L$$PWD/../../dependencies/unarr/win/x64 -lunarr
|
||||
} else {
|
||||
LIBS += -L$$PWD/../../dependencies/unarr/win/x86 -lunarr
|
||||
}
|
||||
DEFINES += use_unarr UNARR_IS_SHARED_LIBRARY
|
||||
}
|
||||
|
||||
else:exists ($$PWD/unarr-master) {
|
||||
message(Found unarr source-code)
|
||||
message(Unarr will be build as a part of YACReader)
|
||||
|
||||
#qmake based unarr build system
|
||||
#this should only be used for testing or as a last resort
|
||||
include(unarr.pro)
|
||||
DEFINES+=use_unarr
|
||||
}
|
||||
else {
|
||||
error(Missing dependency: unarr decrompression backend. Please install libunarr on your system\
|
||||
or provide a copy of the unarr source code in compressed_archive/unarr/unarr-master)
|
||||
}
|
||||
message(Found unarr source-code)
|
||||
message(Unarr will be build as a part of YACReader)
|
||||
|
||||
# qmake based unarr build system
|
||||
# this should only be used for testing or as a last resort
|
||||
include(unarr.pro)
|
||||
DEFINES += use_unarr
|
||||
}
|
||||
|
||||
else {
|
||||
error(Missing dependency: unarr decrompression backend. Please install libunarr on your system\
|
||||
or provide a copy of the unarr source code in compressed_archive/unarr/unarr-master)
|
||||
}
|
||||
|
Reference in New Issue
Block a user