Commit 72e436de authored by Christian Kandeler's avatar Christian Kandeler

SSH: Add ability to create symbolic links on remote host.

Change-Id: I6fda991c342acb2b64fe1e0078e9df43590119c6
Reviewed-on: http://codereview.qt.nokia.com/1531Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent c986374f
......@@ -162,6 +162,12 @@ SftpJobId SftpChannel::renameFileOrDirectory(const QString &oldPath,
new Internal::SftpRename(++d->m_nextJobId, oldPath, newPath)));
}
SftpJobId SftpChannel::createLink(const QString &filePath, const QString &target)
{
return d->createJob(Internal::SftpCreateLink::Ptr(
new Internal::SftpCreateLink(++d->m_nextJobId, filePath, target)));
}
SftpJobId SftpChannel::createFile(const QString &path, SftpOverwriteMode mode)
{
return d->createJob(Internal::SftpCreateFile::Ptr(
......@@ -451,6 +457,7 @@ void SftpChannelPrivate::handleStatus()
case AbstractSftpOperation::Rm:
case AbstractSftpOperation::Rename:
case AbstractSftpOperation::CreateFile:
case AbstractSftpOperation::CreateLink:
handleStatusGeneric(it, response);
break;
}
......
......@@ -73,6 +73,7 @@ public:
SftpJobId renameFileOrDirectory(const QString &oldPath,
const QString &newPath);
SftpJobId createFile(const QString &filePath, SftpOverwriteMode mode);
SftpJobId createLink(const QString &filePath, const QString &target);
SftpJobId uploadFile(const QString &localFilePath,
const QString &remoteFilePath, SftpOverwriteMode mode);
SftpJobId downloadFile(const QString &remoteFilePath,
......
......@@ -90,6 +90,17 @@ SftpOutgoingPacket &SftpRename::initialPacket(SftpOutgoingPacket &packet)
}
SftpCreateLink::SftpCreateLink(SftpJobId jobId, const QString &filePath, const QString &target)
: AbstractSftpOperation(jobId), filePath(filePath), target(target)
{
}
SftpOutgoingPacket &SftpCreateLink::initialPacket(SftpOutgoingPacket &packet)
{
return packet.generateCreateLink(filePath, target, jobId);
}
AbstractSftpOperationWithHandle::AbstractSftpOperationWithHandle(SftpJobId jobId,
const QString &remotePath)
: AbstractSftpOperation(jobId),
......
......@@ -53,7 +53,7 @@ struct AbstractSftpOperation
{
typedef QSharedPointer<AbstractSftpOperation> Ptr;
enum Type {
ListDir, MakeDir, RmDir, Rm, Rename, CreateFile, Download, UploadFile
ListDir, MakeDir, RmDir, Rm, Rename, CreateLink, CreateFile, Download, UploadFile
};
AbstractSftpOperation(SftpJobId jobId);
......@@ -117,6 +117,18 @@ struct SftpRename : public AbstractSftpOperation
const QString newPath;
};
struct SftpCreateLink : public AbstractSftpOperation
{
typedef QSharedPointer<SftpCreateLink> Ptr;
SftpCreateLink(SftpJobId jobId, const QString &filePath, const QString &target);
virtual Type type() const { return CreateLink; }
virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet);
const QString filePath;
const QString target;
};
struct AbstractSftpOperationWithHandle : public AbstractSftpOperation
{
......
......@@ -143,6 +143,12 @@ SftpOutgoingPacket &SftpOutgoingPacket::generateWriteFile(const QByteArray &hand
.appendInt64(offset).appendString(data).finalize();
}
SftpOutgoingPacket &SftpOutgoingPacket::generateCreateLink(const QString &filePath,
const QString &target, quint32 requestId)
{
return init(SSH_FXP_SYMLINK, requestId).appendString(filePath).appendString(target).finalize();
}
SftpOutgoingPacket &SftpOutgoingPacket::generateOpenFile(const QString &path,
OpenType openType, SftpOverwriteMode mode, const QList<quint32> &attributes, quint32 requestId)
{
......
......@@ -64,6 +64,8 @@ public:
quint32 requestId);
SftpOutgoingPacket &generateWriteFile(const QByteArray &handle,
quint64 offset, const QByteArray &data, quint32 requestId);
SftpOutgoingPacket &generateCreateLink(const QString &filePath, const QString &target,
quint32 requestId);
static const quint32 DefaultPermissions;
......
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