| | | 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 SftpSymLinkRequest : SftpRequest |
| | | 8 | | { |
| | | 9 | | private byte[] _newLinkPath; |
| | | 10 | | private byte[] _existingPath; |
| | | 11 | | |
| | | 12 | | public override SftpMessageTypes SftpMessageType |
| | | 13 | | { |
| | 18 | 14 | | get { return SftpMessageTypes.SymLink; } |
| | | 15 | | } |
| | | 16 | | |
| | | 17 | | public string NewLinkPath |
| | | 18 | | { |
| | 9 | 19 | | get { return Encoding.GetString(_newLinkPath, 0, _newLinkPath.Length); } |
| | 27 | 20 | | private set { _newLinkPath = Encoding.GetBytes(value); } |
| | | 21 | | } |
| | | 22 | | |
| | | 23 | | public string ExistingPath |
| | | 24 | | { |
| | 9 | 25 | | get { return Encoding.GetString(_existingPath, 0, _existingPath.Length); } |
| | 27 | 26 | | private set { _existingPath = Encoding.GetBytes(value); } |
| | | 27 | | } |
| | | 28 | | |
| | 36 | 29 | | public Encoding Encoding { get; set; } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Gets the size of the message in bytes. |
| | | 33 | | /// </summary> |
| | | 34 | | /// <value> |
| | | 35 | | /// The size of the messages in bytes. |
| | | 36 | | /// </value> |
| | | 37 | | protected override int BufferCapacity |
| | | 38 | | { |
| | | 39 | | get |
| | 3 | 40 | | { |
| | 3 | 41 | | var capacity = base.BufferCapacity; |
| | 3 | 42 | | capacity += 4; // NewLinkPath length |
| | 3 | 43 | | capacity += _newLinkPath.Length; // NewLinkPath |
| | 3 | 44 | | capacity += 4; // ExistingPath length |
| | 3 | 45 | | capacity += _existingPath.Length; // ExistingPath |
| | 3 | 46 | | return capacity; |
| | 3 | 47 | | } |
| | | 48 | | } |
| | | 49 | | |
| | | 50 | | public SftpSymLinkRequest(uint protocolVersion, uint requestId, string newLinkPath, string existingPath, Encodin |
| | 9 | 51 | | : base(protocolVersion, requestId, statusAction) |
| | 9 | 52 | | { |
| | 9 | 53 | | Encoding = encoding; |
| | 9 | 54 | | NewLinkPath = newLinkPath; |
| | 9 | 55 | | ExistingPath = existingPath; |
| | 9 | 56 | | } |
| | | 57 | | |
| | | 58 | | protected override void LoadData() |
| | 0 | 59 | | { |
| | 0 | 60 | | base.LoadData(); |
| | 0 | 61 | | _newLinkPath = ReadBinary(); |
| | 0 | 62 | | _existingPath = ReadBinary(); |
| | 0 | 63 | | } |
| | | 64 | | |
| | | 65 | | protected override void SaveData() |
| | 3 | 66 | | { |
| | 3 | 67 | | base.SaveData(); |
| | 3 | 68 | | WriteBinaryString(_newLinkPath); |
| | 3 | 69 | | WriteBinaryString(_existingPath); |
| | 3 | 70 | | } |
| | | 71 | | } |
| | | 72 | | } |