| | | 1 | | using System; |
| | | 2 | | using Renci.SshNet.Sftp.Responses; |
| | | 3 | | |
| | | 4 | | namespace Renci.SshNet.Sftp.Requests |
| | | 5 | | { |
| | | 6 | | internal sealed class SftpFSetStatRequest : SftpRequest |
| | | 7 | | { |
| | | 8 | | private byte[] _attributesBytes; |
| | | 9 | | |
| | | 10 | | public override SftpMessageTypes SftpMessageType |
| | | 11 | | { |
| | 30 | 12 | | get { return SftpMessageTypes.FSetStat; } |
| | | 13 | | } |
| | | 14 | | |
| | 30 | 15 | | public byte[] Handle { get; private set; } |
| | | 16 | | |
| | 20 | 17 | | private SftpFileAttributes Attributes { get; set; } |
| | | 18 | | |
| | | 19 | | private byte[] AttributesBytes |
| | | 20 | | { |
| | | 21 | | get |
| | 14 | 22 | | { |
| | 14 | 23 | | _attributesBytes ??= Attributes.GetBytes(); |
| | 14 | 24 | | return _attributesBytes; |
| | 14 | 25 | | } |
| | | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Gets the size of the message in bytes. |
| | | 30 | | /// </summary> |
| | | 31 | | /// <value> |
| | | 32 | | /// The size of the messages in bytes. |
| | | 33 | | /// </value> |
| | | 34 | | protected override int BufferCapacity |
| | | 35 | | { |
| | | 36 | | get |
| | 7 | 37 | | { |
| | 7 | 38 | | var capacity = base.BufferCapacity; |
| | 7 | 39 | | capacity += 4; // Handle length |
| | 7 | 40 | | capacity += Handle.Length; // Handle |
| | 7 | 41 | | capacity += AttributesBytes.Length; // Attributes |
| | 7 | 42 | | return capacity; |
| | 7 | 43 | | } |
| | | 44 | | } |
| | | 45 | | |
| | | 46 | | public SftpFSetStatRequest(uint protocolVersion, uint requestId, byte[] handle, SftpFileAttributes attributes, A |
| | 13 | 47 | | : base(protocolVersion, requestId, statusAction) |
| | 13 | 48 | | { |
| | 13 | 49 | | Handle = handle; |
| | 13 | 50 | | Attributes = attributes; |
| | 13 | 51 | | } |
| | | 52 | | |
| | | 53 | | protected override void LoadData() |
| | 0 | 54 | | { |
| | 0 | 55 | | base.LoadData(); |
| | | 56 | | |
| | 0 | 57 | | Handle = ReadBinary(); |
| | 0 | 58 | | Attributes = ReadAttributes(); |
| | 0 | 59 | | } |
| | | 60 | | |
| | | 61 | | protected override void SaveData() |
| | 7 | 62 | | { |
| | 7 | 63 | | base.SaveData(); |
| | | 64 | | |
| | 7 | 65 | | WriteBinaryString(Handle); |
| | 7 | 66 | | Write(AttributesBytes); |
| | 7 | 67 | | } |
| | | 68 | | } |
| | | 69 | | } |