using System; using Renci.SshNet.Sftp.Responses; namespace Renci.SshNet.Sftp.Requests { internal class SftpReadRequest : SftpRequest { public override SftpMessageTypes SftpMessageType { get { return SftpMessageTypes.Read; } } public byte[] Handle { get; private set; } public UInt64 Offset { get; private set; } public UInt32 Length { get; private set; } #if TUNING /// /// Gets the size of the message in bytes. /// /// /// The size of the messages in bytes. /// protected override int BufferCapacity { get { var capacity = base.BufferCapacity; capacity += 4; // Handle length capacity += Handle.Length; // Handle capacity += 8; // Offset capacity += 4; // Length return capacity; } } #endif public SftpReadRequest(uint protocolVersion, uint requestId, byte[] handle, UInt64 offset, UInt32 length, Action dataAction, Action statusAction) : base(protocolVersion, requestId, statusAction) { this.Handle = handle; this.Offset = offset; this.Length = length; this.SetAction(dataAction); } protected override void LoadData() { base.LoadData(); #if TUNING this.Handle = this.ReadBinary(); #else this.Handle = this.ReadBinaryString(); #endif this.Offset = this.ReadUInt64(); this.Length = this.ReadUInt32(); } protected override void SaveData() { base.SaveData(); this.WriteBinaryString(this.Handle); this.Write(this.Offset); this.Write(this.Length); } } }