SftpRmDirRequest.cs 1.9 KB

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