FileSystemShare.cs 1.9 KB

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