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,37 @@ 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 (renCmd.isEmpty()) { + error(KIO::ERR_CANNOT_RENAME, src.fileName()); + return; + } + + if (src.fileName() == dest.fileName()) { + return; + } + + KrLinecountingProcess proc; + proc << renCmd << arcPath << src.path().replace(arcPath + "/", "") << dest.path().replace(arcPath + "/", ""); + proc.start(); + proc.waitForFinished(); + + if (proc.exitStatus() != QProcess::NormalExit || !checkStatus(proc.exitCode())) { + error(KIO::ERR_CANNOT_RENAME, src.fileName()); + return; + } + + finished(); +} + void kio_krarcProtocol::listDir(const QUrl &url) { KRFUNC; @@ -1479,6 +1510,7 @@ copyCmd = QStringList(); delCmd = QStringList(); putCmd = QStringList(); + renCmd = QStringList(); if (arcType == "zip") { noencoding = true; @@ -1495,6 +1527,10 @@ putCmd << fullPathName("zip") << "-ry"; } + if (!QStandardPaths::findExecutable(QStringLiteral("7za")).isEmpty()) { + renCmd << fullPathName("7za") << "rn"; + } + if (!getPassword().isEmpty()) { getCmd << "-P" << password; copyCmd << "-P" << password; @@ -1609,6 +1645,7 @@ copyCmd << cmd << "e" << "-y"; delCmd << cmd << "d" << "-y"; putCmd << cmd << "a" << "-y"; + renCmd << cmd << "rn"; if (!getPassword().isEmpty()) { getCmd << QString("-p%1").arg(password); listCmd << QString("-p%1").arg(password);