| | | 1 | | using System; |
| | | 2 | | using Renci.SshNet.Sftp.Responses; |
| | | 3 | | |
| | | 4 | | namespace Renci.SshNet.Sftp.Requests |
| | | 5 | | { |
| | | 6 | | internal abstract class SftpExtendedRequest : SftpRequest |
| | | 7 | | { |
| | | 8 | | private byte[] _nameBytes; |
| | | 9 | | private string _name; |
| | | 10 | | |
| | | 11 | | public override SftpMessageTypes SftpMessageType |
| | | 12 | | { |
| | 108 | 13 | | get { return SftpMessageTypes.Extended; } |
| | | 14 | | } |
| | | 15 | | |
| | | 16 | | public string Name |
| | | 17 | | { |
| | | 18 | | get |
| | 18 | 19 | | { |
| | 18 | 20 | | return _name; |
| | 18 | 21 | | } |
| | | 22 | | private set |
| | 54 | 23 | | { |
| | 54 | 24 | | _name = value; |
| | 54 | 25 | | _nameBytes = Utf8.GetBytes(value); |
| | 54 | 26 | | } |
| | | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Gets the size of the message in bytes. |
| | | 31 | | /// </summary> |
| | | 32 | | /// <value> |
| | | 33 | | /// The size of the messages in bytes. |
| | | 34 | | /// </value> |
| | | 35 | | protected override int BufferCapacity |
| | | 36 | | { |
| | | 37 | | get |
| | 24 | 38 | | { |
| | 24 | 39 | | var capacity = base.BufferCapacity; |
| | 24 | 40 | | capacity += 4; // Name length |
| | 24 | 41 | | capacity += _nameBytes.Length; // Name |
| | 24 | 42 | | return capacity; |
| | 24 | 43 | | } |
| | | 44 | | } |
| | | 45 | | |
| | | 46 | | protected SftpExtendedRequest(uint protocolVersion, uint requestId, Action<SftpStatusResponse> statusAction, str |
| | 54 | 47 | | : base(protocolVersion, requestId, statusAction) |
| | 54 | 48 | | { |
| | 54 | 49 | | Name = name; |
| | 54 | 50 | | } |
| | | 51 | | |
| | | 52 | | protected override void SaveData() |
| | 24 | 53 | | { |
| | 24 | 54 | | base.SaveData(); |
| | 24 | 55 | | WriteBinaryString(_nameBytes); |
| | 24 | 56 | | } |
| | | 57 | | } |
| | | 58 | | } |