SftpUnblockRequest.cs 1.9 KB

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