SftpWriteRequest.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 SftpWriteRequest : SftpRequest
  9. {
  10. public override SftpMessageTypes SftpMessageType
  11. {
  12. get { return SftpMessageTypes.Write; }
  13. }
  14. public byte[] Handle { get; private set; }
  15. public UInt64 Offset { get; private set; }
  16. public byte[] Data { get; private set; }
  17. public SftpWriteRequest(uint requestId, byte[] handle, UInt64 offset, byte[] data, Action<SftpStatusResponse> statusAction)
  18. : base(requestId, statusAction)
  19. {
  20. this.Handle = handle;
  21. this.Offset = offset;
  22. this.Data = data;
  23. }
  24. protected override void LoadData()
  25. {
  26. base.LoadData();
  27. this.Handle = this.ReadBinaryString();
  28. this.Offset = this.ReadUInt64();
  29. this.Data = this.ReadBinaryString();
  30. }
  31. protected override void SaveData()
  32. {
  33. base.SaveData();
  34. this.WriteBinaryString(this.Handle);
  35. this.Write(this.Offset);
  36. this.WriteBinaryString(this.Data);
  37. }
  38. }
  39. }