FileSystemShare.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.Server
  12. {
  13. public class FileSystemShare : ISMBShare
  14. {
  15. private string m_name;
  16. public List<string> ReadAccess;
  17. public List<string> WriteAccess;
  18. public IFileSystem FileSystem;
  19. public FileSystemShare(string shareName)
  20. {
  21. m_name = shareName;
  22. }
  23. public bool HasReadAccess(string userName)
  24. {
  25. return Contains(ReadAccess, userName);
  26. }
  27. public bool HasWriteAccess(string userName)
  28. {
  29. return Contains(WriteAccess, userName);
  30. }
  31. public static bool Contains(List<string> list, string value)
  32. {
  33. return (IndexOf(list, value) >= 0);
  34. }
  35. public static int IndexOf(List<string> list, string value)
  36. {
  37. for (int index = 0; index < list.Count; index++)
  38. {
  39. if (string.Equals(list[index], value, StringComparison.InvariantCultureIgnoreCase))
  40. {
  41. return index;
  42. }
  43. }
  44. return -1;
  45. }
  46. public string Name
  47. {
  48. get
  49. {
  50. return m_name;
  51. }
  52. }
  53. }
  54. }