Skip to content

Fix unrar detection on Windows

I couldn't test this with Okular on Windows since I couldn't build it, I tried to install it with craft okular but it failed with fatal error: package libs/ghostscript all failed.

I just tested the code in detectUnrar in a separate application.

    QString unrarPath = QStandardPaths::findExecutable(QStringLiteral("unrar"));
    QProcess proc;
    proc.start(unrarPath, QStringList() << "-v");
    bool ok = proc.waitForFinished(-1);
    Q_UNUSED(ok)
    const  QString out = QString::fromLocal8Bit(proc.readAllStandardOutput());
    const QStringList lines1 = out.split(QLatin1Char('\n'), QString::SkipEmptyParts);
    const QStringList lines2 = out.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);

    qDebug() << "QLatin1Char:" << lines1.first();
    qDebug() << "QRegExp:" << lines2.first();

Result

QLatin1Char: "\r"
QRegExp: "UNRAR 6.00 x86 freeware      Copyright (c) 1993-2020 Alexander Roshal"

On Linux (openSUSE TW) there's no change.

BUG: 412413

Merge request reports