SftpWriteRequest
using Renci.SshNet.Sftp.Responses;
using System;
namespace Renci.SshNet.Sftp.Requests
{
internal class SftpWriteRequest : SftpRequest
{
public override SftpMessageTypes SftpMessageType => SftpMessageTypes.Write;
public byte[] Handle { get; set; }
public ulong ServerFileOffset { get; set; }
public byte[] Data { get; set; }
public int Offset { get; set; }
public int Length { get; set; }
protected override int BufferCapacity => base.BufferCapacity + 4 + Handle.Length + 8 + 4 + Length;
public SftpWriteRequest(uint protocolVersion, uint requestId, byte[] handle, ulong serverFileOffset, byte[] data, int offset, int length, Action<SftpStatusResponse> statusAction)
: base(protocolVersion, requestId, statusAction)
{
Handle = handle;
ServerFileOffset = serverFileOffset;
Data = data;
Offset = offset;
Length = length;
}
protected override void LoadData()
{
base.LoadData();
Handle = ReadBinary();
ServerFileOffset = ReadUInt64();
Data = ReadBinary();
Offset = 0;
Length = Data.Length;
}
protected override void SaveData()
{
base.SaveData();
WriteBinaryString(Handle);
Write(ServerFileOffset);
WriteBinary(Data, Offset, Length);
}
}
}