2
0

SftpFStatRequest.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using Renci.SshNet.Sftp.Responses;
  3. namespace Renci.SshNet.Sftp.Requests
  4. {
  5. internal class SftpFStatRequest : SftpRequest
  6. {
  7. public override SftpMessageTypes SftpMessageType
  8. {
  9. get { return SftpMessageTypes.FStat; }
  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 SftpFStatRequest(uint protocolVersion, uint requestId, byte[] handle, Action<SftpAttrsResponse> attrsAction, Action<SftpStatusResponse> statusAction)
  31. : base(protocolVersion, requestId, statusAction)
  32. {
  33. this.Handle = handle;
  34. this.SetAction(attrsAction);
  35. }
  36. protected override void LoadData()
  37. {
  38. base.LoadData();
  39. #if TUNING
  40. this.Handle = this.ReadBinary();
  41. #else
  42. this.Handle = this.ReadBinaryString();
  43. #endif
  44. }
  45. protected override void SaveData()
  46. {
  47. base.SaveData();
  48. this.WriteBinaryString(this.Handle);
  49. }
  50. }
  51. }