Commit ff4b1345 authored by Ragnar Thomsen's avatar Ragnar Thomsen
Browse files

Add support for overwrite prompt of p7zip v15.09.

The overwrite prompt changed from p7zip version 9.38.1 to 15.09. Add
support for the new prompt. FileExistsExpression had to be changed
from QString to QStringList.

Also, got rid of unneeded CliInterface::checkForFileExistsMessage().
Just use CliInterface::checkForErrorMessage() instead.
parent f2090934
......@@ -660,9 +660,9 @@ void CliInterface::readStdout(bool handleAll)
bool foundErrorMessage =
(wrongPasswordMessage ||
checkForErrorMessage(QLatin1String( lines.last() ), ExtractionFailedPatterns) ||
checkForErrorMessage(QLatin1String(lines.last()), ExtractionFailedPatterns) ||
checkForPasswordPromptMessage(QLatin1String(lines.last())) ||
checkForFileExistsMessage(QLatin1String( lines.last() )));
checkForErrorMessage(QLatin1String(lines.last()), FileExistsExpression));
if (foundErrorMessage) {
handleAll = true;
......@@ -830,18 +830,6 @@ bool CliInterface::checkForPasswordPromptMessage(const QString& line)
return false;
}
bool CliInterface::checkForFileExistsMessage(const QString& line)
{
if (m_existsPattern.pattern().isEmpty()) {
m_existsPattern.setPattern(m_param.value(FileExistsExpression).toString());
}
if (m_existsPattern.match(line).hasMatch()) {
return true;
}
return false;
}
bool CliInterface::handleFileExistsMessage(const QString& line)
{
// Check for a filename and store it.
......@@ -855,7 +843,7 @@ bool CliInterface::handleFileExistsMessage(const QString& line)
}
}
if (!checkForFileExistsMessage(line)) {
if (!checkForErrorMessage(line, FileExistsExpression)) {
return false;
}
......
......@@ -146,9 +146,9 @@ enum CliInterfaceParameters {
*/
PasswordSwitch,
/**
* QString
* This is a regexp, defining how to recognize the last line in a "File
* already exists" prompt when extracting.
* QStringList
* This is a stringlist with regexps, defining how to recognize the last
* line in a "File already exists" prompt when extracting.
*/
FileExistsExpression,
/**
......@@ -325,7 +325,6 @@ private:
bool checkForPasswordPromptMessage(const QString& line);
bool checkForFileExistsMessage(const QString& line);
bool handleFileExistsMessage(const QString& filename);
bool checkForErrorMessage(const QString& line, int parameterIndex);
void handleLine(const QString& line);
......@@ -363,7 +362,6 @@ private:
bool moveToFinalDest(const QVariantList &files, const QString &finalDest, const QTemporaryDir &tmpDir);
QByteArray m_stdOutData;
QRegularExpression m_existsPattern;
QRegularExpression m_passwordPromptPattern;
QHash<int, QList<QRegularExpression> > m_patternCache;
......
......@@ -83,8 +83,11 @@ ParameterList CliPlugin::parameterList() const
<< QStringLiteral("$Archive")
<< QStringLiteral("$Files");
p[FileExistsExpression] = QStringLiteral("^\\(Y\\)es / \\(N\\)o / \\(A\\)lways / \\(S\\)kip all / A\\(u\\)to rename all / \\(Q\\)uit\\? $");
p[FileExistsFileName] = QStringList() << QStringLiteral("^file \\./(.*)$");
p[FileExistsExpression] = QStringList()
<< QStringLiteral("^\\(Y\\)es / \\(N\\)o / \\(A\\)lways / \\(S\\)kip all / A\\(u\\)to rename all / \\(Q\\)uit\\? $")
<< QStringLiteral("^\\? \\(Y\\)es / \\(N\\)o / \\(A\\)lways / \\(S\\)kip all / A\\(u\\)to rename all / \\(Q\\)uit\\? $");
p[FileExistsFileName] = QStringList() << QStringLiteral("^file \\./(.*)$")
<< QStringLiteral("^ Path: \\./(.*)$");
p[FileExistsInput] = QStringList() << QStringLiteral("Y") //overwrite
<< QStringLiteral("N") //skip
<< QStringLiteral("A") //overwrite all
......
......@@ -61,7 +61,7 @@ ParameterList CliPlugin::parameterList() const
p[DeleteArgs] = QStringList() << QLatin1String("d") << QLatin1String("-v") << QLatin1String("$Archive") << QLatin1String("$Files");
p[FileExistsExpression] = QLatin1String("^(.+) OverWrite \\?");
p[FileExistsExpression] = QStringList() << QLatin1String("^(.+) OverWrite \\?");
p[FileExistsFileName] = QStringList() << p[FileExistsExpression].toString();
p[FileExistsMode] = 1; // Watch for messages in stdout
p[FileExistsInput] = QStringList()
......
......@@ -100,7 +100,8 @@ ParameterList CliPlugin::parameterList() const
p[DeleteArgs] = QStringList() << QLatin1String( "d" )
<< QLatin1String( "$Archive" )
<< QLatin1String( "$Files" );
p[FileExistsExpression] = QLatin1String("^\\[Y\\]es, \\[N\\]o, \\[A\\]ll, n\\[E\\]ver, \\[R\\]ename, \\[Q\\]uit $");
p[FileExistsExpression] = QStringList()
<< QLatin1String("^\\[Y\\]es, \\[N\\]o, \\[A\\]ll, n\\[E\\]ver, \\[R\\]ename, \\[Q\\]uit $");
p[FileExistsFileName] = QStringList() << QLatin1String("^(.+) already exists. Overwrite it") // unrar 3 & 4
<< QLatin1String("^Would you like to replace the existing file (.+)$"); // unrar 5
p[FileExistsInput] = QStringList() << QLatin1String( "Y" ) //overwrite
......
......@@ -98,7 +98,8 @@ ParameterList CliPlugin::parameterList() const
<< QStringLiteral("$Archive")
<< QStringLiteral("$Files");
p[FileExistsExpression] = QStringLiteral("^replace (.+)\\? \\[y\\]es, \\[n\\]o, \\[A\\]ll, \\[N\\]one, \\[r\\]ename: $");
p[FileExistsExpression] = QStringList()
<< QStringLiteral("^replace (.+)\\? \\[y\\]es, \\[n\\]o, \\[A\\]ll, \\[N\\]one, \\[r\\]ename: $");
p[FileExistsFileName] = QStringList() << p[FileExistsExpression].toString();
p[FileExistsInput] = QStringList() << QStringLiteral("y") //overwrite
<< QStringLiteral("n") //skip
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment