Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

111 linhas
5.9 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.Security;
  22. namespace Alphaleonis.Win32.Filesystem
  23. {
  24. partial class Directory
  25. {
  26. #region .NET
  27. /// <summary>Determines whether the given path refers to an existing directory on disk.</summary>
  28. /// <returns>
  29. /// <para>Returns <see langword="true"/> if <paramref name="path"/> refers to an existing directory.</para>
  30. /// <para>Returns <see langword="false"/> if the directory does not exist or an error occurs when trying to determine if the specified file exists.</para>
  31. /// </returns>
  32. /// <remarks>
  33. /// The Exists method returns <see langword="false"/> if any error occurs while trying to determine if the specified file exists.
  34. /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters,
  35. /// a failing or missing disk, or if the caller does not have permission to read the file.
  36. /// </remarks>
  37. /// <param name="path">The path to test.</param>
  38. [SecurityCritical]
  39. public static bool Exists(string path)
  40. {
  41. return File.ExistsCore(true, null, path, PathFormat.RelativePath);
  42. }
  43. #endregion // .NET
  44. /// <summary>[AlphaFS] Determines whether the given path refers to an existing directory on disk.</summary>
  45. /// <returns>
  46. /// <para>Returns <see langword="true"/> if <paramref name="path"/> refers to an existing directory.</para>
  47. /// <para>Returns <see langword="false"/> if the directory does not exist or an error occurs when trying to determine if the specified file exists.</para>
  48. /// </returns>
  49. /// <remarks>
  50. /// The Exists method returns <see langword="false"/> if any error occurs while trying to determine if the specified file exists.
  51. /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters,
  52. /// a failing or missing disk, or if the caller does not have permission to read the file.
  53. /// </remarks>
  54. /// <param name="path">The path to test.</param>
  55. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  56. [SecurityCritical]
  57. public static bool Exists(string path, PathFormat pathFormat)
  58. {
  59. return File.ExistsCore(true, null, path, pathFormat);
  60. }
  61. #region Transactional
  62. /// <summary>[AlphaFS] Determines whether the given path refers to an existing directory on disk.</summary>
  63. /// <returns>
  64. /// <para>Returns <see langword="true"/> if <paramref name="path"/> refers to an existing directory.</para>
  65. /// <para>Returns <see langword="false"/> if the directory does not exist or an error occurs when trying to determine if the specified file exists.</para>
  66. /// </returns>
  67. /// <remarks>
  68. /// The Exists method returns <see langword="false"/> if any error occurs while trying to determine if the specified file exists.
  69. /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters,
  70. /// a failing or missing disk, or if the caller does not have permission to read the file.
  71. /// </remarks>
  72. /// <param name="transaction">The transaction.</param>
  73. /// <param name="path">The path to test.</param>
  74. [SecurityCritical]
  75. public static bool ExistsTransacted(KernelTransaction transaction, string path)
  76. {
  77. return File.ExistsCore(true, transaction, path, PathFormat.RelativePath);
  78. }
  79. /// <summary>[AlphaFS] Determines whether the given path refers to an existing directory on disk.</summary>
  80. /// <returns>
  81. /// <para>Returns <see langword="true"/> if <paramref name="path"/> refers to an existing directory.</para>
  82. /// <para>Returns <see langword="false"/> if the directory does not exist or an error occurs when trying to determine if the specified file exists.</para>
  83. /// </returns>
  84. /// <remarks>
  85. /// The Exists method returns <see langword="false"/> if any error occurs while trying to determine if the specified file exists.
  86. /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters,
  87. /// a failing or missing disk, or if the caller does not have permission to read the file.
  88. /// </remarks>
  89. /// <param name="transaction">The transaction.</param>
  90. /// <param name="path">The path to test.</param>
  91. /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
  92. [SecurityCritical]
  93. public static bool ExistsTransacted(KernelTransaction transaction, string path, PathFormat pathFormat)
  94. {
  95. return File.ExistsCore(true, transaction, path, pathFormat);
  96. }
  97. #endregion // Transactional
  98. }
  99. }