| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | using Renci.SshNet.Sftp.Responses; |
| | | 4 | | |
| | | 5 | | namespace Renci.SshNet.Sftp.Requests |
| | | 6 | | { |
| | | 7 | | internal sealed class SftpFStatRequest : SftpRequest |
| | | 8 | | { |
| | | 9 | | private readonly Action<SftpAttrsResponse> _attrsAction; |
| | | 10 | | |
| | | 11 | | public override SftpMessageTypes SftpMessageType |
| | | 12 | | { |
| | 357 | 13 | | get { return SftpMessageTypes.FStat; } |
| | | 14 | | } |
| | | 15 | | |
| | 360 | 16 | | public byte[] Handle { get; private set; } |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets the size of the message in bytes. |
| | | 20 | | /// </summary> |
| | | 21 | | /// <value> |
| | | 22 | | /// The size of the messages in bytes. |
| | | 23 | | /// </value> |
| | | 24 | | protected override int BufferCapacity |
| | | 25 | | { |
| | | 26 | | get |
| | 116 | 27 | | { |
| | 116 | 28 | | var capacity = base.BufferCapacity; |
| | 116 | 29 | | capacity += 4; // Handle length |
| | 116 | 30 | | capacity += Handle.Length; // Handle |
| | 116 | 31 | | return capacity; |
| | 116 | 32 | | } |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | public SftpFStatRequest(uint protocolVersion, uint requestId, byte[] handle, Action<SftpAttrsResponse> attrsActi |
| | 125 | 36 | | : base(protocolVersion, requestId, statusAction) |
| | 125 | 37 | | { |
| | 125 | 38 | | Handle = handle; |
| | 125 | 39 | | _attrsAction = attrsAction; |
| | 125 | 40 | | } |
| | | 41 | | |
| | | 42 | | protected override void LoadData() |
| | 0 | 43 | | { |
| | 0 | 44 | | base.LoadData(); |
| | 0 | 45 | | Handle = ReadBinary(); |
| | 0 | 46 | | } |
| | | 47 | | |
| | | 48 | | protected override void SaveData() |
| | 116 | 49 | | { |
| | 116 | 50 | | base.SaveData(); |
| | 116 | 51 | | WriteBinaryString(Handle); |
| | 116 | 52 | | } |
| | | 53 | | |
| | | 54 | | public override void Complete(SftpResponse response) |
| | 119 | 55 | | { |
| | 119 | 56 | | if (response is SftpAttrsResponse attrsResponse) |
| | 116 | 57 | | { |
| | 116 | 58 | | _attrsAction(attrsResponse); |
| | 116 | 59 | | } |
| | | 60 | | else |
| | 3 | 61 | | { |
| | 3 | 62 | | base.Complete(response); |
| | 3 | 63 | | } |
| | 119 | 64 | | } |
| | | 65 | | } |
| | | 66 | | } |