SftpCloseRequest.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using Renci.SshNet.Sftp.Responses;
  3. namespace Renci.SshNet.Sftp.Requests
  4. {
  5. internal class SftpCloseRequest : SftpRequest
  6. {
  7. public override SftpMessageTypes SftpMessageType
  8. {
  9. get { return SftpMessageTypes.Close; }
  10. }
  11. public byte[] Handle { get; private set; }
  12. #if TUNING
  13. /// <summary>
  14. /// Gets the size of the message in bytes.
  15. /// </summary>
  16. /// <value>
  17. /// The size of the messages in bytes.
  18. /// </value>
  19. protected override int BufferCapacity
  20. {
  21. get
  22. {
  23. var capacity = base.BufferCapacity;
  24. capacity += 4; // Handle length
  25. capacity += Handle.Length; // Handle
  26. return capacity;
  27. }
  28. }
  29. #endif
  30. public SftpCloseRequest(uint protocolVersion, uint requestId, byte[] handle, Action<SftpStatusResponse> statusAction)
  31. : base(protocolVersion, requestId, statusAction)
  32. {
  33. this.Handle = handle;
  34. }
  35. protected override void LoadData()
  36. {
  37. base.LoadData();
  38. #if TUNING
  39. this.Handle = this.ReadBinary();
  40. #else
  41. this.Handle = this.ReadBinaryString();
  42. #endif
  43. }
  44. protected override void SaveData()
  45. {
  46. base.SaveData();
  47. this.WriteBinaryString(this.Handle);
  48. }
  49. }
  50. }