FileSystemShare.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Copyright (C) 2014 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.Server
  12. {
  13. public class FileSystemShare
  14. {
  15. public string Name;
  16. public List<string> ReadAccess;
  17. public List<string> WriteAccess;
  18. public IFileSystem FileSystem;
  19. public bool HasReadAccess(string userName)
  20. {
  21. return Contains(ReadAccess, userName);
  22. }
  23. public bool HasWriteAccess(string userName)
  24. {
  25. return Contains(WriteAccess, userName);
  26. }
  27. public static bool Contains(List<string> list, string value)
  28. {
  29. return (IndexOf(list, value) >= 0);
  30. }
  31. public static int IndexOf(List<string> list, string value)
  32. {
  33. for (int index = 0; index < list.Count; index++)
  34. {
  35. if (string.Equals(list[index], value, StringComparison.InvariantCultureIgnoreCase))
  36. {
  37. return index;
  38. }
  39. }
  40. return -1;
  41. }
  42. }
  43. }