Extract 7z loading to it's own function

This will unify 7z loading in all scenarios and it also fixes the search path in Linux, now the apps will always try to load 7z.so from LIBDIR/yacreader/7z.so, if it fails they'll try 7zip/7z.so
This commit is contained in:
Luis Ángel San Martín
2024-09-15 15:50:09 +02:00
parent bb36368ad2
commit 63fcde8035
5 changed files with 26 additions and 24 deletions

View File

@ -1,6 +1,8 @@
#include "yacreader_global.h"
#include <QModelIndex>
#include <QLibrary>
#include <QCoreApplication>
using namespace YACReader;
@ -119,3 +121,17 @@ void YACReader::iterate(const QModelIndex &index,
for (int i = 0; i < rows; ++i)
iterate(model->index(i, 0, index), model, iteration);
}
QLibrary *YACReader::load7zLibrary()
{
#if defined Q_OS_UNIX && !defined Q_OS_MACOS
auto yacreader7zPath = QString(LIBDIR) + "/yacreader/7z.so";
if (QLibrary::isLibrary(yacreader7zPath)) {
return new QLibrary(yacreader7zPath);
} else {
return new QLibrary(QString(LIBDIR) + "/7zip/7z.so");
}
#else
return new QLibrary(QCoreApplication::applicationDirPath() + "/utils/7z");
#endif
}