SetInformation.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. public abstract class SetInformation
  14. {
  15. public abstract byte[] GetBytes();
  16. public abstract SetInformationLevel InformationLevel
  17. {
  18. get;
  19. }
  20. public static SetInformation GetSetInformation(byte[] buffer, SetInformationLevel informationLevel)
  21. {
  22. switch (informationLevel)
  23. {
  24. case SetInformationLevel.SMB_SET_FILE_BASIC_INFO:
  25. return new SetFileBasicInfo(buffer);
  26. case SetInformationLevel.SMB_SET_FILE_DISPOSITION_INFO:
  27. return new SetFileDispositionInfo(buffer);
  28. case SetInformationLevel.SMB_SET_FILE_ALLOCATION_INFO:
  29. return new SetFileAllocationInfo(buffer);
  30. case SetInformationLevel.SMB_SET_FILE_END_OF_FILE_INFO:
  31. return new SetFileEndOfFileInfo(buffer);
  32. default:
  33. throw new UnsupportedInformationLevelException();
  34. }
  35. }
  36. }
  37. }