| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | using Renci.SshNet.Sftp.Responses; |
| | | 4 | | |
| | | 5 | | namespace Renci.SshNet.Sftp.Requests |
| | | 6 | | { |
| | | 7 | | internal sealed class SftpBlockRequest : SftpRequest |
| | | 8 | | { |
| | | 9 | | public override SftpMessageTypes SftpMessageType |
| | | 10 | | { |
| | 18 | 11 | | get { return SftpMessageTypes.Block; } |
| | | 12 | | } |
| | | 13 | | |
| | 18 | 14 | | public byte[] Handle { get; private set; } |
| | | 15 | | |
| | 15 | 16 | | public ulong Offset { get; private set; } |
| | | 17 | | |
| | 15 | 18 | | public ulong Length { get; private set; } |
| | | 19 | | |
| | 15 | 20 | | public uint LockMask { get; private set; } |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Gets the size of the message in bytes. |
| | | 24 | | /// </summary> |
| | | 25 | | /// <value> |
| | | 26 | | /// The size of the messages in bytes. |
| | | 27 | | /// </value> |
| | | 28 | | protected override int BufferCapacity |
| | | 29 | | { |
| | | 30 | | get |
| | 3 | 31 | | { |
| | 3 | 32 | | var capacity = base.BufferCapacity; |
| | 3 | 33 | | capacity += 4; // Handle length |
| | 3 | 34 | | capacity += Handle.Length; // Handle |
| | 3 | 35 | | capacity += 8; // Offset |
| | 3 | 36 | | capacity += 8; // Length |
| | 3 | 37 | | capacity += 4; // LockMask |
| | 3 | 38 | | return capacity; |
| | 3 | 39 | | } |
| | | 40 | | } |
| | | 41 | | |
| | | 42 | | public SftpBlockRequest(uint protocolVersion, uint requestId, byte[] handle, ulong offset, ulong length, uint lo |
| | 9 | 43 | | : base(protocolVersion, requestId, statusAction) |
| | 9 | 44 | | { |
| | 9 | 45 | | Handle = handle; |
| | 9 | 46 | | Offset = offset; |
| | 9 | 47 | | Length = length; |
| | 9 | 48 | | LockMask = lockMask; |
| | 9 | 49 | | } |
| | | 50 | | |
| | | 51 | | protected override void LoadData() |
| | 0 | 52 | | { |
| | 0 | 53 | | base.LoadData(); |
| | | 54 | | |
| | 0 | 55 | | Handle = ReadBinary(); |
| | 0 | 56 | | Offset = ReadUInt64(); |
| | 0 | 57 | | Length = ReadUInt64(); |
| | 0 | 58 | | LockMask = ReadUInt32(); |
| | 0 | 59 | | } |
| | | 60 | | |
| | | 61 | | protected override void SaveData() |
| | 3 | 62 | | { |
| | 3 | 63 | | base.SaveData(); |
| | | 64 | | |
| | 3 | 65 | | WriteBinaryString(Handle); |
| | 3 | 66 | | Write(Offset); |
| | 3 | 67 | | Write(Length); |
| | 3 | 68 | | Write(LockMask); |
| | 3 | 69 | | } |
| | | 70 | | } |
| | | 71 | | } |