| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | using Renci.SshNet.Sftp.Responses; |
| | | 4 | | |
| | | 5 | | namespace Renci.SshNet.Sftp.Requests |
| | | 6 | | { |
| | | 7 | | internal sealed class HardLinkRequest : SftpExtendedRequest |
| | | 8 | | { |
| | | 9 | | private byte[] _oldPath; |
| | | 10 | | private byte[] _newPath; |
| | | 11 | | |
| | | 12 | | public string OldPath |
| | | 13 | | { |
| | 9 | 14 | | get { return Utf8.GetString(_oldPath, 0, _oldPath.Length); } |
| | 27 | 15 | | private set { _oldPath = Utf8.GetBytes(value); } |
| | | 16 | | } |
| | | 17 | | |
| | | 18 | | public string NewPath |
| | | 19 | | { |
| | 9 | 20 | | get { return Utf8.GetString(_newPath, 0, _newPath.Length); } |
| | 27 | 21 | | private set { _newPath = Utf8.GetBytes(value); } |
| | | 22 | | } |
| | | 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 |
| | 3 | 33 | | { |
| | 3 | 34 | | var capacity = base.BufferCapacity; |
| | 3 | 35 | | capacity += 4; // OldPath length |
| | 3 | 36 | | capacity += _oldPath.Length; // OldPath |
| | 3 | 37 | | capacity += 4; // NewPath length |
| | 3 | 38 | | capacity += _newPath.Length; // NewPath |
| | 3 | 39 | | return capacity; |
| | 3 | 40 | | } |
| | | 41 | | } |
| | | 42 | | |
| | | 43 | | public HardLinkRequest(uint protocolVersion, uint requestId, string oldPath, string newPath, Action<SftpStatusRe |
| | 9 | 44 | | : base(protocolVersion, requestId, statusAction, "hardlink@openssh.com") |
| | 9 | 45 | | { |
| | 9 | 46 | | OldPath = oldPath; |
| | 9 | 47 | | NewPath = newPath; |
| | 9 | 48 | | } |
| | | 49 | | |
| | | 50 | | protected override void SaveData() |
| | 3 | 51 | | { |
| | 3 | 52 | | base.SaveData(); |
| | 3 | 53 | | WriteBinaryString(_oldPath); |
| | 3 | 54 | | WriteBinaryString(_newPath); |
| | 3 | 55 | | } |
| | | 56 | | } |
| | | 57 | | } |