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