diff --git a/krArc/krarc.h b/krArc/krarc.h --- a/krArc/krarc.h +++ b/krArc/krarc.h @@ -50,6 +50,7 @@ virtual void listDir(const QUrl &url) Q_DECL_OVERRIDE; virtual void del(QUrl const & url, bool isFile) Q_DECL_OVERRIDE; virtual void copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags) Q_DECL_OVERRIDE; + virtual void rename(const QUrl &src, const QUrl & dest, KIO::JobFlags flags) Q_DECL_OVERRIDE; public slots: void receivedData(KProcess *, QByteArray &); @@ -76,6 +77,7 @@ QStringList delCmd; ///< delete files command. QStringList putCmd; ///< add file command. QStringList copyCmd; ///< copy to file command. + QStringList renCmd; ///< rename file command. private: void get(const QUrl &url, int tries); diff --git a/krArc/krarc.cpp b/krArc/krarc.cpp --- a/krArc/krarc.cpp +++ b/krArc/krarc.cpp @@ -760,6 +760,25 @@ error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, 74)); } +void kio_krarcProtocol::rename(const QUrl& src, const QUrl& dest, KIO::JobFlags flags) +{ + KRDEBUG("renaming from: " << src.path() << " to: " << dest.path()); + KRDEBUG("command: " << arcPath); + + if (!checkWriteSupport()) + return; + + if (src.fileName() == dest.fileName()) + return; + + KrLinecountingProcess proc; + proc << renCmd << arcPath << src.path().replace(arcPath + "/", "") << dest.path().replace(arcPath + "/", ""); + proc.start(); + proc.waitForFinished(); + + finished(); +} + void kio_krarcProtocol::listDir(const QUrl &url) { KRFUNC; @@ -1479,6 +1498,7 @@ copyCmd = QStringList(); delCmd = QStringList(); putCmd = QStringList(); + renCmd = QStringList(); if (arcType == "zip") { noencoding = true; @@ -1495,6 +1515,12 @@ putCmd << fullPathName("zip") << "-ry"; } + if (QStandardPaths::findExecutable(QStringLiteral("7za")).isEmpty()) { + renCmd = QStringList(); + } else { + renCmd << fullPathName("7za") << "rn"; + } + if (!getPassword().isEmpty()) { getCmd << "-P" << password; copyCmd << "-P" << password;