From 418caf1b2716e481ed4d95a2541cd5efdf122351 Mon Sep 17 00:00:00 2001 From: Peter Franz Date: Wed, 5 Oct 2022 08:13:03 +1300 Subject: [PATCH] SFTP upload directory make append dir path optional --- src/libs/qssh/sftpchannel.cpp | 8 +++++--- src/libs/qssh/sftpchannel.h | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libs/qssh/sftpchannel.cpp b/src/libs/qssh/sftpchannel.cpp index 3612e6f..95e1ab5 100644 --- a/src/libs/qssh/sftpchannel.cpp +++ b/src/libs/qssh/sftpchannel.cpp @@ -239,7 +239,7 @@ SftpJobId SftpChannel::downloadFile(const QString &remoteFilePath, QSharedPointe } SftpJobId SftpChannel::uploadDir(const QString &localDirPath, - const QString &remoteParentDirPath) + const QString &remoteParentDirPath, bool appendDirPath) { if (state() != Initialized) return SftpInvalidJob; @@ -248,8 +248,10 @@ SftpJobId SftpChannel::uploadDir(const QString &localDirPath, return SftpInvalidJob; const Internal::SftpUploadDir::Ptr uploadDirOp( new Internal::SftpUploadDir(++d->m_nextJobId)); - const QString remoteDirPath - = remoteParentDirPath + u'/' + localDir.dirName(); + QString remoteDirPath = remoteParentDirPath; + if (appendDirPath) { + remoteDirPath += u'/' + localDir.dirName(); + } const Internal::SftpMakeDir::Ptr mkdirOp( new Internal::SftpMakeDir(++d->m_nextJobId, remoteDirPath, uploadDirOp)); uploadDirOp->mkdirsInProgress.insert(mkdirOp, diff --git a/src/libs/qssh/sftpchannel.h b/src/libs/qssh/sftpchannel.h index ee577ea..daa1bc0 100644 --- a/src/libs/qssh/sftpchannel.h +++ b/src/libs/qssh/sftpchannel.h @@ -202,11 +202,11 @@ class QSSH_EXPORT SftpChannel : public QObject /*! * \brief Uploads a local directory (recursively) with files to the remote host * \param localDirPath The path to an existing local directory - * \param remoteParentDirPath The remote path to upload it to, the name of the local directory will be appended to this + * \param remoteParentDirPath The remote path to upload it to, the name of the local directory will be appended to this if appendDirPath is set * \return A unique ID identifying this job */ SftpJobId uploadDir(const QString &localDirPath, - const QString &remoteParentDirPath); + const QString &remoteParentDirPath, bool appendDirPath = true); /*! * \brief Downloads a remote directory (recursively) to a local path