| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | using Renci.SshNet.Sftp.Responses; |
| | | 4 | | |
| | | 5 | | namespace Renci.SshNet.Sftp.Requests |
| | | 6 | | { |
| | | 7 | | internal sealed class FStatVfsRequest : SftpExtendedRequest |
| | | 8 | | { |
| | | 9 | | private readonly Action<SftpExtendedReplyResponse> _extendedReplyAction; |
| | | 10 | | |
| | 21 | 11 | | public byte[] Handle { get; private set; } |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets the size of the message in bytes. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <value> |
| | | 17 | | /// The size of the messages in bytes. |
| | | 18 | | /// </value> |
| | | 19 | | protected override int BufferCapacity |
| | | 20 | | { |
| | | 21 | | get |
| | 3 | 22 | | { |
| | 3 | 23 | | var capacity = base.BufferCapacity; |
| | 3 | 24 | | capacity += 4; // Handle length |
| | 3 | 25 | | capacity += Handle.Length; // Handle |
| | 3 | 26 | | return capacity; |
| | 3 | 27 | | } |
| | | 28 | | } |
| | | 29 | | |
| | | 30 | | public FStatVfsRequest(uint protocolVersion, uint requestId, byte[] handle, Action<SftpExtendedReplyResponse> ex |
| | 12 | 31 | | : base(protocolVersion, requestId, statusAction, "fstatvfs@openssh.com") |
| | 12 | 32 | | { |
| | 12 | 33 | | Handle = handle; |
| | | 34 | | |
| | 12 | 35 | | _extendedReplyAction = extendedAction; |
| | 12 | 36 | | } |
| | | 37 | | |
| | | 38 | | protected override void SaveData() |
| | 3 | 39 | | { |
| | 3 | 40 | | base.SaveData(); |
| | 3 | 41 | | WriteBinaryString(Handle); |
| | 3 | 42 | | } |
| | | 43 | | |
| | | 44 | | public override void Complete(SftpResponse response) |
| | 6 | 45 | | { |
| | 6 | 46 | | if (response is SftpExtendedReplyResponse extendedReplyResponse) |
| | 3 | 47 | | { |
| | 3 | 48 | | _extendedReplyAction(extendedReplyResponse); |
| | 3 | 49 | | } |
| | | 50 | | else |
| | 3 | 51 | | { |
| | 3 | 52 | | base.Complete(response); |
| | 3 | 53 | | } |
| | 6 | 54 | | } |
| | | 55 | | } |
| | | 56 | | } |