[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeutils/ark
From:       Raphael Kubo da Costa <kubito () gmail ! com>
Date:       2011-05-26 4:03:40
Message-ID: 20110526040340.DD2CDAC869 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1233575 by rkcosta:

Make CliInterface::escapeFileName() more general.

Instead of always escaping some characters with backslashes,
CliInterface::escapeFileName() is now a virtual method which should be
reimplemented by any plugin which needs to, and the default
implementation just returns an unchanged QString.

For now, only clizipplugin reimplements it by prefixing some
characters with backslashes.

Forwardport of r1233571.

 M  +2 -25     kerfuffle/cliinterface.cpp  
 M  +5 -5      kerfuffle/cliinterface.h  
 M  +23 -3     plugins/clizipplugin/cliplugin.cpp  
 M  +2 -0      plugins/clizipplugin/cliplugin.h  


--- trunk/KDE/kdeutils/ark/kerfuffle/cliinterface.cpp #1233574:1233575
@@ -684,34 +684,11 @@
     }
 }
 
-QString CliInterface::escapedCharacters()
+QString CliInterface::escapeFileName(const QString& fileName) const
 {
-    return m_escapedCharacters;
+    return fileName;
 }
 
-void CliInterface::setEscapedCharacters(const QString& characters)
-{
-    m_escapedCharacters = characters;
-}
-
-QString CliInterface::escapeFileName(const QString& fileName)
-{
-    QString quoted;
-    const int len = fileName.length();
-    const QLatin1Char backslash('\\');
-    quoted.reserve(len * 2);
-
-    for (int i = 0; i < len; ++i) {
-        if (m_escapedCharacters.contains(fileName.at(i))) {
-            quoted.append(backslash);
-        }
-
-        quoted.append(fileName.at(i));
-    }
-
-    return quoted;
-}
-
 void CliInterface::writeToProcess(const QByteArray& data)
 {
     Q_ASSERT(m_process);
--- trunk/KDE/kdeutils/ark/kerfuffle/cliinterface.h #1233574:1233575
@@ -302,12 +302,14 @@
     bool runProcess(const QString& programName, const QStringList& arguments);
 
     /**
-     * Precedes the characters returned by escapedCharacters() with a
-     * backslash in @p fileName.
+     * Performs any additional escaping and processing on @p fileName
+     * before passing it to the underlying process.
      *
+     * The default implementation returns @p fileName unchanged.
+     *
      * @param fileName String to escape.
      */
-    QString escapeFileName(const QString& fileName);
+    virtual QString escapeFileName(const QString &fileName) const;
 
     /**
      * Wrapper around KProcess::write() or KPtyDevice::write(), depending on
@@ -329,8 +331,6 @@
     ParameterList m_param;
     QVariantList m_removedFiles;
 
-    QString m_escapedCharacters;
-
 private slots:
     void started();
     void readStdout(bool handleAll = false);
--- trunk/KDE/kdeutils/ark/plugins/clizipplugin/cliplugin.cpp #1233574:1233575
@@ -38,15 +38,35 @@
     : CliInterface(parent, args)
     , m_status(Header)
 {
-    // #208091: infozip applies special meanings to some characters
-    //          see match.c in infozip's source code
-    setEscapedCharacters(QLatin1String("[]*?^-\\!"));
 }
 
 CliPlugin::~CliPlugin()
 {
 }
 
+// #208091: infozip applies special meanings to some characters, so we
+//          need to escape them with backslashes.see match.c in
+//          infozip's source code
+QString CliPlugin::escapeFileName(const QString &fileName) const
+{
+    const QString escapedCharacters(QLatin1String("[]*?^-\\!"));
+
+    QString quoted;
+    const int len = fileName.length();
+    const QLatin1Char backslash('\\');
+    quoted.reserve(len * 2);
+
+    for (int i = 0; i < len; ++i) {
+        if (escapedCharacters.contains(fileName.at(i))) {
+            quoted.append(backslash);
+        }
+
+        quoted.append(fileName.at(i));
+    }
+
+    return quoted;
+}
+
 ParameterList CliPlugin::parameterList() const
 {
     static ParameterList p;
--- trunk/KDE/kdeutils/ark/plugins/clizipplugin/cliplugin.h #1233574:1233575
@@ -31,6 +31,8 @@
     explicit CliPlugin(QObject *parent, const QVariantList &args);
     virtual ~CliPlugin();
 
+    virtual QString escapeFileName(const QString &fileName) const;
+
     virtual Kerfuffle::ParameterList parameterList() const;
 
     virtual bool readListLine(const QString &line);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic