| | | 1 | | using System; |
| | | 2 | | using System.Text; |
| | | 3 | | using Renci.SshNet.Sftp.Responses; |
| | | 4 | | |
| | | 5 | | namespace Renci.SshNet.Sftp.Requests |
| | | 6 | | { |
| | | 7 | | internal sealed class SftpRemoveRequest : SftpRequest |
| | | 8 | | { |
| | | 9 | | private byte[] _fileName; |
| | | 10 | | |
| | | 11 | | public override SftpMessageTypes SftpMessageType |
| | | 12 | | { |
| | 504 | 13 | | get { return SftpMessageTypes.Remove; } |
| | | 14 | | } |
| | | 15 | | |
| | | 16 | | public string Filename |
| | | 17 | | { |
| | 9 | 18 | | get { return Encoding.GetString(_fileName, 0, _fileName.Length); } |
| | 513 | 19 | | private set { _fileName = Encoding.GetBytes(value); } |
| | | 20 | | } |
| | | 21 | | |
| | 348 | 22 | | public Encoding Encoding { get; private set; } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Gets the size of the message in bytes. |
| | | 26 | | /// </summary> |
| | | 27 | | /// <value> |
| | | 28 | | /// The size of the messages in bytes. |
| | | 29 | | /// </value> |
| | | 30 | | protected override int BufferCapacity |
| | | 31 | | { |
| | | 32 | | get |
| | 165 | 33 | | { |
| | 165 | 34 | | var capacity = base.BufferCapacity; |
| | 165 | 35 | | capacity += 4; // FileName length |
| | 165 | 36 | | capacity += _fileName.Length; // FileName |
| | 165 | 37 | | return capacity; |
| | 165 | 38 | | } |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | public SftpRemoveRequest(uint protocolVersion, uint requestId, string filename, Encoding encoding, Action<SftpSt |
| | 171 | 42 | | : base(protocolVersion, requestId, statusAction) |
| | 171 | 43 | | { |
| | 171 | 44 | | Encoding = encoding; |
| | 171 | 45 | | Filename = filename; |
| | 171 | 46 | | } |
| | | 47 | | |
| | | 48 | | protected override void LoadData() |
| | 0 | 49 | | { |
| | 0 | 50 | | base.LoadData(); |
| | 0 | 51 | | _fileName = ReadBinary(); |
| | 0 | 52 | | } |
| | | 53 | | |
| | | 54 | | protected override void SaveData() |
| | 165 | 55 | | { |
| | 165 | 56 | | base.SaveData(); |
| | 165 | 57 | | WriteBinaryString(_fileName); |
| | 165 | 58 | | } |
| | | 59 | | } |
| | | 60 | | } |