SftpOpenRequest.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Renci.SshNet.Sftp.Responses;
  6. namespace Renci.SshNet.Sftp.Requests
  7. {
  8. internal class SftpOpenRequest : SftpRequest
  9. {
  10. public override SftpMessageTypes SftpMessageType
  11. {
  12. get { return SftpMessageTypes.Open; }
  13. }
  14. public string Filename { get; private set; }
  15. public Flags Flags { get; private set; }
  16. public SftpFileAttributes Attributes { get; private set; }
  17. public SftpOpenRequest(uint requestId, string fileName, Flags flags, Action<SftpHandleResponse> handleAction, Action<SftpStatusResponse> statusAction)
  18. : this(requestId, fileName, flags, SftpFileAttributes.Empty, handleAction, statusAction)
  19. {
  20. }
  21. public SftpOpenRequest(uint requestId, string fileName, Flags flags, SftpFileAttributes attributes, Action<SftpHandleResponse> handleAction, Action<SftpStatusResponse> statusAction)
  22. : base(requestId, statusAction)
  23. {
  24. this.Filename = fileName;
  25. this.Flags = flags;
  26. this.Attributes = attributes;
  27. this.SetAction(handleAction);
  28. }
  29. protected override void LoadData()
  30. {
  31. base.LoadData();
  32. throw new NotSupportedException();
  33. }
  34. protected override void SaveData()
  35. {
  36. base.SaveData();
  37. this.Write(this.Filename);
  38. this.Write((uint)this.Flags);
  39. this.Write(this.Attributes);
  40. }
  41. }
  42. }