Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

168 wiersze
12 KiB

  1. /* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. using System;
  22. using System.Security;
  23. namespace Alphaleonis.Win32.Filesystem
  24. {
  25. partial class Directory
  26. {
  27. #region .NET
  28. /// <summary>Sets the date and time that the specified directory was last written to.</summary>
  29. /// <param name="path">The directory for which to set the date and time information.</param>
  30. /// <param name="lastWriteTime">A <see cref="System.DateTime"/> containing the value to set for the last write date and time of <paramref name="path"/>. This value is expressed in local time.</param>
  31. [SecurityCritical]
  32. public static void SetLastWriteTime(string path, DateTime lastWriteTime)
  33. {
  34. File.SetFsoDateTimeCore(true, null, path, null, null, lastWriteTime.ToUniversalTime(), false, PathFormat.RelativePath);
  35. }
  36. /// <summary>Sets the date and time, in coordinated universal time (UTC), that the specified directory was last written to.</summary>
  37. /// <param name="path">The directory for which to set the date and time information.</param>
  38. /// <param name="lastWriteTimeUtc">A <see cref="System.DateTime"/> containing the value to set for the last write date and time of <paramref name="path"/>. This value is expressed in UTC time.</param>
  39. [SecurityCritical]
  40. public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc)
  41. {
  42. File.SetFsoDateTimeCore(true, null, path, null, null, lastWriteTimeUtc, false, PathFormat.RelativePath);
  43. }
  44. #endregion // .NET
  45. /// <summary>[AlphaFS] Sets the date and time that the specified directory was last written to.</summary>
  46. /// <param name="path">The directory for which to set the date and time information.</param>
  47. /// <param name="lastWriteTime">A <see cref="System.DateTime"/> containing the value to set for the last write date and time of <paramref name="path"/>. This value is expressed in local time.</param>
  48. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  49. [SecurityCritical]
  50. public static void SetLastWriteTime(string path, DateTime lastWriteTime, PathFormat pathFormat)
  51. {
  52. File.SetFsoDateTimeCore(true, null, path, null, null, lastWriteTime.ToUniversalTime(), false, pathFormat);
  53. }
  54. /// <summary>[AlphaFS] Sets the date and time that the specified directory was last written to.</summary>
  55. /// <param name="path">The directory for which to set the date and time information.</param>
  56. /// <param name="lastWriteTime">A <see cref="System.DateTime"/> containing the value to set for the last write date and time of <paramref name="path"/>. This value is expressed in local time.</param>
  57. /// <param name="modifyReparsePoint">If <see langword="true"/>, the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if <paramref name="path"/> does not refer to a reparse point.</param>
  58. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  59. [SecurityCritical]
  60. public static void SetLastWriteTime(string path, DateTime lastWriteTime, bool modifyReparsePoint, PathFormat pathFormat)
  61. {
  62. File.SetFsoDateTimeCore(true, null, path, null, null, lastWriteTime.ToUniversalTime(), modifyReparsePoint, pathFormat);
  63. }
  64. /// <summary>[AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last written to.</summary>
  65. /// <param name="path">The directory for which to set the date and time information.</param>
  66. /// <param name="lastWriteTimeUtc">A <see cref="System.DateTime"/> containing the value to set for the last write date and time of <paramref name="path"/>. This value is expressed in UTC time.</param>
  67. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  68. [SecurityCritical]
  69. public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc, PathFormat pathFormat)
  70. {
  71. File.SetFsoDateTimeCore(true, null, path, null, null, lastWriteTimeUtc, false, pathFormat);
  72. }
  73. /// <summary>[AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last written to.</summary>
  74. /// <param name="path">The directory for which to set the date and time information.</param>
  75. /// <param name="lastWriteTimeUtc">A <see cref="System.DateTime"/> containing the value to set for the last write date and time of <paramref name="path"/>. This value is expressed in UTC time.</param>
  76. /// <param name="modifyReparsePoint">If <see langword="true"/>, the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if <paramref name="path"/> does not refer to a reparse point.</param>
  77. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  78. [SecurityCritical]
  79. public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc, bool modifyReparsePoint, PathFormat pathFormat)
  80. {
  81. File.SetFsoDateTimeCore(true, null, path, null, null, lastWriteTimeUtc, modifyReparsePoint, pathFormat);
  82. }
  83. #region Transactional
  84. /// <summary>[AlphaFS] Sets the date and time that the specified directory was last written to.</summary>
  85. /// <param name="transaction">The transaction.</param>
  86. /// <param name="path">The directory for which to set the date and time information.</param>
  87. /// <param name="lastWriteTime">A <see cref="System.DateTime"/> containing the value to set for the last write date and time of <paramref name="path"/>. This value is expressed in local time.</param>
  88. [SecurityCritical]
  89. public static void SetLastWriteTimeTransacted(KernelTransaction transaction, string path, DateTime lastWriteTime)
  90. {
  91. File.SetFsoDateTimeCore(true, transaction, path, null, null, lastWriteTime.ToUniversalTime(), false, PathFormat.RelativePath);
  92. }
  93. /// <summary>[AlphaFS] Sets the date and time that the specified directory was last written to.</summary>
  94. /// <param name="transaction">The transaction.</param>
  95. /// <param name="path">The directory for which to set the date and time information.</param>
  96. /// <param name="lastWriteTime">A <see cref="System.DateTime"/> containing the value to set for the last write date and time of <paramref name="path"/>. This value is expressed in local time.</param>
  97. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  98. [SecurityCritical]
  99. public static void SetLastWriteTimeTransacted(KernelTransaction transaction, string path, DateTime lastWriteTime, PathFormat pathFormat)
  100. {
  101. File.SetFsoDateTimeCore(true, transaction, path, null, null, lastWriteTime.ToUniversalTime(), false, pathFormat);
  102. }
  103. /// <summary>[AlphaFS] Sets the date and time that the specified directory was last written to.</summary>
  104. /// <param name="transaction">The transaction.</param>
  105. /// <param name="path">The directory for which to set the date and time information.</param>
  106. /// <param name="lastWriteTime">A <see cref="System.DateTime"/> containing the value to set for the last write date and time of <paramref name="path"/>. This value is expressed in local time.</param>
  107. /// <param name="modifyReparsePoint">If <see langword="true"/>, the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if <paramref name="path"/> does not refer to a reparse point.</param>
  108. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  109. [SecurityCritical]
  110. public static void SetLastWriteTimeTransacted(KernelTransaction transaction, string path, DateTime lastWriteTime, bool modifyReparsePoint, PathFormat pathFormat)
  111. {
  112. File.SetFsoDateTimeCore(true, transaction, path, null, null, lastWriteTime.ToUniversalTime(), modifyReparsePoint, pathFormat);
  113. }
  114. /// <summary>[AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last written to.</summary>
  115. /// <param name="transaction">The transaction.</param>
  116. /// <param name="path">The directory for which to set the date and time information.</param>
  117. /// <param name="lastWriteTimeUtc">A <see cref="System.DateTime"/> containing the value to set for the last write date and time of <paramref name="path"/>. This value is expressed in UTC time.</param>
  118. [SecurityCritical]
  119. public static void SetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastWriteTimeUtc)
  120. {
  121. File.SetFsoDateTimeCore(true, transaction, path, null, null, lastWriteTimeUtc, false, PathFormat.RelativePath);
  122. }
  123. /// <summary>[AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last written to.</summary>
  124. /// <param name="transaction">The transaction.</param>
  125. /// <param name="path">The directory for which to set the date and time information.</param>
  126. /// <param name="lastWriteTimeUtc">A <see cref="System.DateTime"/> containing the value to set for the last write date and time of <paramref name="path"/>. This value is expressed in UTC time.</param>
  127. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  128. [SecurityCritical]
  129. public static void SetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastWriteTimeUtc, PathFormat pathFormat)
  130. {
  131. File.SetFsoDateTimeCore(true, transaction, path, null, null, lastWriteTimeUtc, false, pathFormat);
  132. }
  133. /// <summary>[AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last written to.</summary>
  134. /// <param name="transaction">The transaction.</param>
  135. /// <param name="path">The directory for which to set the date and time information.</param>
  136. /// <param name="lastWriteTimeUtc">A <see cref="System.DateTime"/> containing the value to set for the last write date and time of <paramref name="path"/>. This value is expressed in UTC time.</param>
  137. /// <param name="modifyReparsePoint">If <see langword="true"/>, the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if <paramref name="path"/> does not refer to a reparse point.</param>
  138. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  139. [SecurityCritical]
  140. public static void SetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastWriteTimeUtc, bool modifyReparsePoint, PathFormat pathFormat)
  141. {
  142. File.SetFsoDateTimeCore(true, transaction, path, null, null, lastWriteTimeUtc, modifyReparsePoint, pathFormat);
  143. }
  144. #endregion // Transactional
  145. }
  146. }