Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

139 rader
8.2 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 Microsoft.Win32.SafeHandles;
  22. using System;
  23. using System.Security;
  24. namespace Alphaleonis.Win32.Filesystem
  25. {
  26. partial class Directory
  27. {
  28. /// <summary>[AlphaFS] Gets the change date and time of the specified directory.</summary>
  29. /// <returns>A <see cref="System.DateTime"/> structure set to the change date and time for the specified directory. This value is expressed in local time.</returns>
  30. /// <param name="path">The directory for which to obtain creation date and time information.</param>
  31. [SecurityCritical]
  32. public static DateTime GetChangeTime(string path)
  33. {
  34. return File.GetChangeTimeCore(true, null, null, path, false, PathFormat.RelativePath);
  35. }
  36. /// <summary>[AlphaFS] Gets the change date and time of the specified directory.</summary>
  37. /// <returns>A <see cref="System.DateTime"/> structure set to the change date and time for the specified directory. This value is expressed in local time.</returns>
  38. /// <param name="path">The directory for which to obtain creation date and time information.</param>
  39. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  40. [SecurityCritical]
  41. public static DateTime GetChangeTime(string path, PathFormat pathFormat)
  42. {
  43. return File.GetChangeTimeCore(true, null, null, path, false, pathFormat);
  44. }
  45. /// <summary>[AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory.</summary>
  46. /// <returns>A <see cref="System.DateTime"/> structure set to the change date and time for the specified directory. This value is expressed in UTC time.</returns>
  47. /// <param name="path">The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format.</param>
  48. [SecurityCritical]
  49. public static DateTime GetChangeTimeUtc(string path)
  50. {
  51. return File.GetChangeTimeCore(true, null, null, path, true, PathFormat.RelativePath);
  52. }
  53. /// <summary>[AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory.</summary>
  54. /// <returns>A <see cref="System.DateTime"/> structure set to the change date and time for the specified directory. This value is expressed in UTC time.</returns>
  55. /// <param name="path">The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format.</param>
  56. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  57. [SecurityCritical]
  58. public static DateTime GetChangeTimeUtc(string path, PathFormat pathFormat)
  59. {
  60. return File.GetChangeTimeCore(true, null, null, path, true, pathFormat);
  61. }
  62. /// <summary>[AlphaFS] Gets the change date and time of the specified directory.</summary>
  63. /// <returns>A <see cref="System.DateTime"/> structure set to the change date and time for the specified directory. This value is expressed in local time.</returns>
  64. /// <param name="safeHandle">An open handle to the directory from which to retrieve information.</param>
  65. [SecurityCritical]
  66. public static DateTime GetChangeTime(SafeFileHandle safeHandle)
  67. {
  68. return File.GetChangeTimeCore(true, null, safeHandle, null, false, PathFormat.RelativePath);
  69. }
  70. /// <summary>[AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory.</summary>
  71. /// <returns>A <see cref="System.DateTime"/> structure set to the change date and time for the specified directory. This value is expressed in UTC time.</returns>
  72. /// <param name="safeHandle">An open handle to the directory from which to retrieve information.</param>
  73. [SecurityCritical]
  74. public static DateTime GetChangeTimeUtc(SafeFileHandle safeHandle)
  75. {
  76. return File.GetChangeTimeCore(true, null, safeHandle, null, true, PathFormat.RelativePath);
  77. }
  78. #region Transactional
  79. /// <summary>[AlphaFS] Gets the change date and time of the specified directory.</summary>
  80. /// <returns>A <see cref="System.DateTime"/> structure set to the change date and time for the specified directory. This value is expressed in local time.</returns>
  81. /// <param name="transaction">The transaction.</param>
  82. /// <param name="path">The directory for which to obtain creation date and time information.</param>
  83. [SecurityCritical]
  84. public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, string path)
  85. {
  86. return File.GetChangeTimeCore(true, transaction, null, path, false, PathFormat.RelativePath);
  87. }
  88. /// <summary>[AlphaFS] Gets the change date and time of the specified directory.</summary>
  89. /// <returns>A <see cref="System.DateTime"/> structure set to the change date and time for the specified directory. This value is expressed in local time.</returns>
  90. /// <param name="transaction">The transaction.</param>
  91. /// <param name="path">The directory for which to obtain creation date and time information.</param>
  92. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  93. [SecurityCritical]
  94. public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
  95. {
  96. return File.GetChangeTimeCore(true, transaction, null, path, false, pathFormat);
  97. }
  98. /// <summary>[AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory.</summary>
  99. /// <returns>A <see cref="System.DateTime"/> structure set to the change date and time for the specified directory. This value is expressed in UTC time.</returns>
  100. /// <param name="transaction">The transaction.</param>
  101. /// <param name="path">The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format.</param>
  102. [SecurityCritical]
  103. public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, string path)
  104. {
  105. return File.GetChangeTimeCore(true, transaction, null, path, true, PathFormat.RelativePath);
  106. }
  107. /// <summary>[AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory.</summary>
  108. /// <returns>A <see cref="System.DateTime"/> structure set to the change date and time for the specified directory. This value is expressed in UTC time.</returns>
  109. /// <param name="transaction">The transaction.</param>
  110. /// <param name="path">The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format.</param>
  111. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  112. [SecurityCritical]
  113. public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
  114. {
  115. return File.GetChangeTimeCore(true, transaction, null, path, true, pathFormat);
  116. }
  117. #endregion // Transactional
  118. }
  119. }