SetFileDispositionInfo.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace SMBLibrary.SMB1
  12. {
  13. /// <summary>
  14. /// SMB_SET_FILE_DISPOSITION_INFO
  15. /// </summary>
  16. public class SetFileDispositionInfo : SetInformation
  17. {
  18. public const int Length = 1;
  19. /// <summary>
  20. /// Indicate that a file SHOULD be deleted when it is closed.
  21. /// </summary>
  22. public bool DeletePending;
  23. public SetFileDispositionInfo()
  24. {
  25. }
  26. public SetFileDispositionInfo(byte[] buffer) : this(buffer, 0)
  27. {
  28. }
  29. public SetFileDispositionInfo(byte[] buffer, int offset)
  30. {
  31. DeletePending = (ByteReader.ReadByte(buffer, ref offset) > 0);
  32. }
  33. public override byte[] GetBytes()
  34. {
  35. byte[] buffer = new byte[Length];
  36. ByteWriter.WriteByte(buffer, 0, Convert.ToByte(DeletePending));
  37. return buffer;
  38. }
  39. public override SetInformationLevel InformationLevel
  40. {
  41. get
  42. {
  43. return SetInformationLevel.SMB_SET_FILE_DISPOSITION_INFO;
  44. }
  45. }
  46. }
  47. }