WebDavFileInfoBase.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. using System;
  2. using System.IO;
  3. namespace WebDAVSharp.Server.Stores.BaseClasses
  4. {
  5. /// <summary>
  6. /// </summary>
  7. public abstract class WebDavFileInfoBase : IWebDavFileInfo
  8. {
  9. /// <summary>
  10. /// </summary>
  11. public string Path { get; set; }
  12. /// <summary>
  13. /// Whether the file exists
  14. /// </summary>
  15. public bool Exists { get; set; }
  16. /// <summary>
  17. /// </summary>
  18. public bool Archive { get; set; }
  19. /// <summary>
  20. /// </summary>
  21. public bool Compressed { get; set; }
  22. /// <summary>
  23. /// </summary>
  24. public bool Device { get; set; }
  25. /// <summary>
  26. /// </summary>
  27. public bool Directory { get; set; }
  28. /// <summary>
  29. /// </summary>
  30. public bool Encrypted { get; set; }
  31. /// <summary>
  32. /// </summary>
  33. public bool Hidden { get; set; }
  34. /// <summary>
  35. /// </summary>
  36. public bool IntegrityStream { get; set; }
  37. /// <summary>
  38. /// </summary>
  39. public bool Normal { get; set; }
  40. /// <summary>
  41. /// </summary>
  42. public bool NoScrubData { get; set; }
  43. /// <summary>
  44. /// </summary>
  45. public bool NotContentIndexed { get; set; }
  46. /// <summary>
  47. /// </summary>
  48. public bool Offline { get; set; }
  49. /// <summary>
  50. /// </summary>
  51. public bool ReadOnly { get; set; }
  52. /// <summary>
  53. /// </summary>
  54. public bool ReparsePoint { get; set; }
  55. /// <summary>
  56. /// </summary>
  57. public bool SparseFile { get; set; }
  58. /// <summary>
  59. /// </summary>
  60. public bool System { get; set; }
  61. /// <summary>
  62. /// </summary>
  63. public bool Temporary { get; set; }
  64. /// <summary>
  65. /// </summary>
  66. public DateTime CreationTime { get; set; }
  67. /// <summary>
  68. /// </summary>
  69. public DateTime LastAccessTime { get; set; }
  70. /// <summary>
  71. /// </summary>
  72. public DateTime? LastWriteTime { get; set; }
  73. /// <summary>
  74. /// </summary>
  75. public abstract void Apply();
  76. /// <summary>
  77. /// </summary>
  78. /// <returns></returns>
  79. public FileAttributes GetAttributes()
  80. {
  81. FileAttributes fa = new FileAttributes();
  82. if (Archive)
  83. fa = fa | FileAttributes.Archive;
  84. if (Compressed)
  85. fa = fa | FileAttributes.Compressed;
  86. if (Device)
  87. fa = fa | FileAttributes.Device;
  88. if (Directory)
  89. fa = fa | FileAttributes.Directory;
  90. if (Encrypted)
  91. fa = fa | FileAttributes.Encrypted;
  92. if (Hidden)
  93. fa = fa | FileAttributes.Hidden;
  94. if (IntegrityStream)
  95. fa = fa | FileAttributes.IntegrityStream;
  96. if (Normal)
  97. fa = fa | FileAttributes.Normal;
  98. if (NoScrubData)
  99. fa = fa | FileAttributes.NoScrubData;
  100. if (NotContentIndexed)
  101. fa = fa | FileAttributes.NotContentIndexed;
  102. if (Offline)
  103. fa = fa | FileAttributes.Offline;
  104. if (ReadOnly)
  105. fa = fa | FileAttributes.ReadOnly;
  106. if (ReparsePoint)
  107. fa = fa | FileAttributes.ReparsePoint;
  108. if (SparseFile)
  109. fa = fa | FileAttributes.SparseFile;
  110. if (System)
  111. fa = fa | FileAttributes.System;
  112. if (Temporary)
  113. fa = fa | FileAttributes.Temporary;
  114. return fa;
  115. }
  116. /// <summary>
  117. /// </summary>
  118. /// <param name="fa"></param>
  119. public void ApplyAttributes(FileAttributes fa)
  120. {
  121. Archive = (fa & FileAttributes.Archive) == FileAttributes.Archive;
  122. Compressed = (fa & FileAttributes.Compressed) == FileAttributes.Compressed;
  123. Device = (fa & FileAttributes.Device) == FileAttributes.Device;
  124. Directory = (fa & FileAttributes.Directory) == FileAttributes.Directory;
  125. Encrypted = (fa & FileAttributes.Encrypted) == FileAttributes.Encrypted;
  126. Hidden = (fa & FileAttributes.Hidden) == FileAttributes.Hidden;
  127. IntegrityStream = (fa & FileAttributes.IntegrityStream) == FileAttributes.IntegrityStream;
  128. Normal = (fa & FileAttributes.Normal) == FileAttributes.Normal;
  129. NoScrubData = (fa & FileAttributes.NoScrubData) == FileAttributes.NoScrubData;
  130. NotContentIndexed = (fa & FileAttributes.NotContentIndexed) == FileAttributes.NotContentIndexed;
  131. Offline = (fa & FileAttributes.Offline) == FileAttributes.Offline;
  132. ReadOnly = (fa & FileAttributes.ReadOnly) == FileAttributes.ReadOnly;
  133. ReparsePoint = (fa & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint;
  134. SparseFile = (fa & FileAttributes.SparseFile) == FileAttributes.SparseFile;
  135. System = (fa & FileAttributes.System) == FileAttributes.System;
  136. Temporary = (fa & FileAttributes.Temporary) == FileAttributes.Temporary;
  137. }
  138. }
  139. }