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

Add CliInterface::resetParsing()

This function is overridden in the individual CliPlugins and resets
parsing variables, such as ParseState, m_comment, etc. This is needed
because an archive can be listed several times without the plugin being
reloaded, e.g. after adding files. This can result in e.g. comments
being appended to themselves or parsing being started in the wrong
ParseState.
resetParsing() is called in CliInterface::list(), before running the
list process.
parent 5d957dca
......@@ -91,6 +91,7 @@ void CliInterface::setListEmptyLines(bool emptyLines)
bool CliInterface::list()
{
resetParsing();
cacheParameterList();
m_operationMode = List;
......
......@@ -267,6 +267,7 @@ public:
virtual bool addFiles(const QStringList & files, const CompressionOptions& options) Q_DECL_OVERRIDE;
virtual bool deleteFiles(const QList<QVariant> & files) Q_DECL_OVERRIDE;
virtual void resetParsing() = 0;
virtual ParameterList parameterList() const = 0;
virtual bool readListLine(const QString &line) = 0;
......
......@@ -49,6 +49,11 @@ CliPlugin::~CliPlugin()
{
}
void CliPlugin::resetParsing()
{
m_state = ReadStateHeader;
}
ParameterList CliPlugin::parameterList() const
{
static ParameterList p;
......
......@@ -35,6 +35,7 @@ public:
virtual ~CliPlugin();
protected:
virtual void resetParsing();
virtual Kerfuffle::ParameterList parameterList() const;
virtual bool readListLine(const QString &line);
......
......@@ -46,6 +46,11 @@ CliPlugin::~CliPlugin()
{
}
void CliPlugin::resetParsing()
{
m_status = Header;
}
ParameterList CliPlugin::parameterList() const
{
static ParameterList p;
......
......@@ -31,8 +31,8 @@ public:
explicit CliPlugin(QObject *parent, const QVariantList &args);
virtual ~CliPlugin();
virtual void resetParsing();
virtual Kerfuffle::ParameterList parameterList() const;
virtual bool readListLine(const QString &line);
private:
......
......@@ -52,6 +52,13 @@ CliPlugin::~CliPlugin()
{
}
void CliPlugin::resetParsing()
{
m_parseState = ParseStateTitle;
m_remainingIgnoreLines = 1;
m_comment.clear();
}
// #272281: the proprietary unrar program does not like trailing '/'s
// in directories passed to it when extracting only part of
// the files in an archive.
......
......@@ -31,13 +31,11 @@ class CliPlugin : public Kerfuffle::CliInterface
public:
explicit CliPlugin(QObject *parent, const QVariantList &args);
virtual ~CliPlugin();
virtual void resetParsing();
virtual QString escapeFileName(const QString &fileName) const;
virtual Kerfuffle::ParameterList parameterList() const;
virtual bool readListLine(const QString &line);
private:
......
......@@ -47,6 +47,11 @@ CliPlugin::~CliPlugin()
{
}
void CliPlugin::resetParsing()
{
m_status = Header;
}
// #208091: infozip applies special meanings to some characters, so we
// need to escape them with backslashes.see match.c in
// infozip's source code
......
......@@ -31,10 +31,9 @@ public:
explicit CliPlugin(QObject *parent, const QVariantList &args);
virtual ~CliPlugin();
virtual void resetParsing();
virtual QString escapeFileName(const QString &fileName) const Q_DECL_OVERRIDE;
virtual Kerfuffle::ParameterList parameterList() const Q_DECL_OVERRIDE;
virtual bool readListLine(const QString &line) Q_DECL_OVERRIDE;
private:
......
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