diff --git a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateAlternateDataStreams.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateAlternateDataStreams.cs index 3937a2329..897252710 100644 --- a/AlphaFS/Filesystem/Directory Class/Directory.EnumerateAlternateDataStreams.cs +++ b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateAlternateDataStreams.cs @@ -32,7 +32,7 @@ public static partial class Directory [SecurityCritical] public static IEnumerable EnumerateAlternateDataStreams(string path) { - return File.EnumerateAlternateDataStreamsCore(null, path, PathFormat.RelativePath); + return File.EnumerateAlternateDataStreamsCore(null, true, path, PathFormat.RelativePath); } /// [AlphaFS] Enumerates the streams of type :$DATA from the specified directory. @@ -42,7 +42,7 @@ public static IEnumerable EnumerateAlternateDataStreams [SecurityCritical] public static IEnumerable EnumerateAlternateDataStreams(string path, PathFormat pathFormat) { - return File.EnumerateAlternateDataStreamsCore(null, path, pathFormat); + return File.EnumerateAlternateDataStreamsCore(null, true, path, pathFormat); } /// [AlphaFS] Enumerates the streams of type :$DATA from the specified directory. @@ -52,7 +52,7 @@ public static IEnumerable EnumerateAlternateDataStreams [SecurityCritical] public static IEnumerable EnumerateAlternateDataStreamsTransacted(KernelTransaction transaction, string path) { - return File.EnumerateAlternateDataStreamsCore(transaction, path, PathFormat.RelativePath); + return File.EnumerateAlternateDataStreamsCore(transaction, true, path, PathFormat.RelativePath); } /// [AlphaFS] Enumerates the streams of type :$DATA from the specified directory. @@ -63,7 +63,7 @@ public static IEnumerable EnumerateAlternateDataStreams [SecurityCritical] public static IEnumerable EnumerateAlternateDataStreamsTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) { - return File.EnumerateAlternateDataStreamsCore(transaction, path, pathFormat); + return File.EnumerateAlternateDataStreamsCore(transaction, true, path, pathFormat); } } } diff --git a/AlphaFS/Filesystem/Directory Class/Directory.GetChangeTime.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetChangeTime.cs index dc0dbed5c..52fee33bf 100644 --- a/AlphaFS/Filesystem/Directory Class/Directory.GetChangeTime.cs +++ b/AlphaFS/Filesystem/Directory Class/Directory.GetChangeTime.cs @@ -33,7 +33,7 @@ public static partial class Directory [SecurityCritical] public static DateTime GetChangeTime(string path) { - return File.GetChangeTimeCore(null, null, path, false, PathFormat.RelativePath); + return File.GetChangeTimeCore(null, null, true, path, false, PathFormat.RelativePath); } /// [AlphaFS] Gets the change date and time of the specified directory. @@ -43,7 +43,7 @@ public static DateTime GetChangeTime(string path) [SecurityCritical] public static DateTime GetChangeTime(string path, PathFormat pathFormat) { - return File.GetChangeTimeCore(null, null, path, false, pathFormat); + return File.GetChangeTimeCore(null, null, true, path, false, pathFormat); } @@ -54,7 +54,7 @@ public static DateTime GetChangeTime(string path, PathFormat pathFormat) [SecurityCritical] public static DateTime GetChangeTimeUtc(string path) { - return File.GetChangeTimeCore(null, null, path, true, PathFormat.RelativePath); + return File.GetChangeTimeCore(null, null, true, path, true, PathFormat.RelativePath); } /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory. @@ -64,7 +64,7 @@ public static DateTime GetChangeTimeUtc(string path) [SecurityCritical] public static DateTime GetChangeTimeUtc(string path, PathFormat pathFormat) { - return File.GetChangeTimeCore(null, null, path, true, pathFormat); + return File.GetChangeTimeCore(null, null, true, path, true, pathFormat); } @@ -75,7 +75,7 @@ public static DateTime GetChangeTimeUtc(string path, PathFormat pathFormat) [SecurityCritical] public static DateTime GetChangeTime(SafeFileHandle safeFileHandle) { - return File.GetChangeTimeCore(null, safeFileHandle, null, false, PathFormat.RelativePath); + return File.GetChangeTimeCore(null, safeFileHandle, true, null, false, PathFormat.RelativePath); } /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory. @@ -84,7 +84,7 @@ public static DateTime GetChangeTime(SafeFileHandle safeFileHandle) [SecurityCritical] public static DateTime GetChangeTimeUtc(SafeFileHandle safeFileHandle) { - return File.GetChangeTimeCore(null, safeFileHandle, null, true, PathFormat.RelativePath); + return File.GetChangeTimeCore(null, safeFileHandle, true, null, true, PathFormat.RelativePath); } #region Transactional @@ -96,7 +96,7 @@ public static DateTime GetChangeTimeUtc(SafeFileHandle safeFileHandle) [SecurityCritical] public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, string path) { - return File.GetChangeTimeCore(transaction, null, path, false, PathFormat.RelativePath); + return File.GetChangeTimeCore(transaction, null, true, path, false, PathFormat.RelativePath); } /// [AlphaFS] Gets the change date and time of the specified directory. @@ -107,7 +107,7 @@ public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, st [SecurityCritical] public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) { - return File.GetChangeTimeCore(transaction, null, path, false, pathFormat); + return File.GetChangeTimeCore(transaction, null, true, path, false, pathFormat); } @@ -119,7 +119,7 @@ public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, st [SecurityCritical] public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, string path) { - return File.GetChangeTimeCore(transaction, null, path, true, PathFormat.RelativePath); + return File.GetChangeTimeCore(transaction, null, true, path, true, PathFormat.RelativePath); } /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory. @@ -130,7 +130,7 @@ public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, [SecurityCritical] public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) { - return File.GetChangeTimeCore(transaction, null, path, true, pathFormat); + return File.GetChangeTimeCore(transaction, null, true, path, true, pathFormat); } #endregion // Transactional diff --git a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateAlternateDataStreams.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateAlternateDataStreams.cs index ea701187a..a9954d7ec 100644 --- a/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateAlternateDataStreams.cs +++ b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateAlternateDataStreams.cs @@ -31,7 +31,7 @@ public sealed partial class DirectoryInfo [SecurityCritical] public IEnumerable EnumerateAlternateDataStreams() { - return File.EnumerateAlternateDataStreamsCore(Transaction, LongFullName, PathFormat.LongFullPath); + return File.EnumerateAlternateDataStreamsCore(Transaction, true, LongFullName, PathFormat.LongFullPath); } } } diff --git a/AlphaFS/Filesystem/File Class/File.EnumerateAlternateDataStreams.cs b/AlphaFS/Filesystem/File Class/File.EnumerateAlternateDataStreams.cs index f7fc7b786..c2c18b1f6 100644 --- a/AlphaFS/Filesystem/File Class/File.EnumerateAlternateDataStreams.cs +++ b/AlphaFS/Filesystem/File Class/File.EnumerateAlternateDataStreams.cs @@ -33,7 +33,7 @@ public static partial class File [SecurityCritical] public static IEnumerable EnumerateAlternateDataStreams(string path) { - return EnumerateAlternateDataStreamsCore(null, path, PathFormat.RelativePath); + return EnumerateAlternateDataStreamsCore(null, false, path, PathFormat.RelativePath); } /// [AlphaFS] Enumerates the streams of type :$DATA from the specified file. @@ -43,7 +43,7 @@ public static IEnumerable EnumerateAlternateDataStreams [SecurityCritical] public static IEnumerable EnumerateAlternateDataStreams(string path, PathFormat pathFormat) { - return EnumerateAlternateDataStreamsCore(null, path, pathFormat); + return EnumerateAlternateDataStreamsCore(null, false, path, pathFormat); } /// [AlphaFS] Enumerates the streams of type :$DATA from the specified file. @@ -53,7 +53,7 @@ public static IEnumerable EnumerateAlternateDataStreams [SecurityCritical] public static IEnumerable EnumerateAlternateDataStreamsTransacted(KernelTransaction transaction, string path) { - return EnumerateAlternateDataStreamsCore(transaction, path, PathFormat.RelativePath); + return EnumerateAlternateDataStreamsCore(transaction, false, path, PathFormat.RelativePath); } /// [AlphaFS] Enumerates the streams of type :$DATA from the specified file. @@ -64,7 +64,7 @@ public static IEnumerable EnumerateAlternateDataStreams [SecurityCritical] public static IEnumerable EnumerateAlternateDataStreamsTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) { - return EnumerateAlternateDataStreamsCore(transaction, path, pathFormat); + return EnumerateAlternateDataStreamsCore(transaction, false, path, pathFormat); } @@ -74,10 +74,11 @@ public static IEnumerable EnumerateAlternateDataStreams /// [AlphaFS] Enumerates the streams of type :$DATA from the specified file or directory. /// The transaction. + /// When true indicates the source is a directory; file otherwise. /// The path to the file or directory to enumerate streams of. /// Indicates the format of the path parameter(s). /// The streams of type :$DATA in the specified file or directory. - internal static IEnumerable EnumerateAlternateDataStreamsCore(KernelTransaction transaction, string path, PathFormat pathFormat) + internal static IEnumerable EnumerateAlternateDataStreamsCore(KernelTransaction transaction, bool isFolder, string path, PathFormat pathFormat) { using (var buffer = new SafeGlobalMemoryBufferHandle(Marshal.SizeOf(typeof(NativeMethods.WIN32_FIND_STREAM_DATA)))) { @@ -116,7 +117,7 @@ internal static IEnumerable EnumerateAlternateDataStrea if (lastError == Win32Errors.ERROR_HANDLE_EOF) break; - NativeError.ThrowException(lastError, pathLp); + NativeError.ThrowException(lastError, isFolder, pathLp); } } } diff --git a/AlphaFS/Filesystem/File Class/File.GetChangeTime.cs b/AlphaFS/Filesystem/File Class/File.GetChangeTime.cs index 335c8022a..8a2fd9a53 100644 --- a/AlphaFS/Filesystem/File Class/File.GetChangeTime.cs +++ b/AlphaFS/Filesystem/File Class/File.GetChangeTime.cs @@ -42,7 +42,7 @@ public static partial class File [SecurityCritical] public static DateTime GetChangeTime(string path, PathFormat pathFormat) { - return GetChangeTimeCore(null, null, path, false, pathFormat); + return GetChangeTimeCore(null, null, false, path, false, pathFormat); } @@ -53,7 +53,7 @@ public static DateTime GetChangeTime(string path, PathFormat pathFormat) [SecurityCritical] public static DateTime GetChangeTime(string path) { - return GetChangeTimeCore(null, null, path, false, PathFormat.RelativePath); + return GetChangeTimeCore(null, null, false, path, false, PathFormat.RelativePath); } /// [AlphaFS] Gets the change date and time of the specified file. @@ -63,7 +63,7 @@ public static DateTime GetChangeTime(string path) [SecurityCritical] public static DateTime GetChangeTime(SafeFileHandle safeFileHandle) { - return GetChangeTimeCore(null, safeFileHandle, null, false, PathFormat.LongFullPath); + return GetChangeTimeCore(null, safeFileHandle, false, null, false, PathFormat.LongFullPath); } /// [AlphaFS] Gets the change date and time of the specified file. @@ -75,7 +75,7 @@ public static DateTime GetChangeTime(SafeFileHandle safeFileHandle) [SecurityCritical] public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) { - return GetChangeTimeCore(transaction, null, path, false, pathFormat); + return GetChangeTimeCore(transaction, null, false, path, false, pathFormat); } /// [AlphaFS] Gets the change date and time of the specified file. @@ -86,7 +86,7 @@ public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, st [SecurityCritical] public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, string path) { - return GetChangeTimeCore(transaction, null, path, false, PathFormat.RelativePath); + return GetChangeTimeCore(transaction, null, false, path, false, PathFormat.RelativePath); } #endregion // GetChangeTime @@ -102,7 +102,7 @@ public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, st [SecurityCritical] public static DateTime GetChangeTimeUtc(string path, PathFormat pathFormat) { - return GetChangeTimeCore(null, null, path, true, pathFormat); + return GetChangeTimeCore(null, null, false, path, true, pathFormat); } /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified file. @@ -112,7 +112,7 @@ public static DateTime GetChangeTimeUtc(string path, PathFormat pathFormat) [SecurityCritical] public static DateTime GetChangeTimeUtc(string path) { - return GetChangeTimeCore(null, null, path, true, PathFormat.RelativePath); + return GetChangeTimeCore(null, null, false, path, true, PathFormat.RelativePath); } /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified file. @@ -122,7 +122,7 @@ public static DateTime GetChangeTimeUtc(string path) [SecurityCritical] public static DateTime GetChangeTimeUtc(SafeFileHandle safeFileHandle) { - return GetChangeTimeCore(null, safeFileHandle, null, true, PathFormat.LongFullPath); + return GetChangeTimeCore(null, safeFileHandle, false, null, true, PathFormat.LongFullPath); } /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified file. @@ -134,7 +134,7 @@ public static DateTime GetChangeTimeUtc(SafeFileHandle safeFileHandle) [SecurityCritical] public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) { - return GetChangeTimeCore(transaction, null, path, true, pathFormat); + return GetChangeTimeCore(transaction, null, false, path, true, pathFormat); } /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified file. @@ -145,7 +145,7 @@ public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, [SecurityCritical] public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, string path) { - return GetChangeTimeCore(transaction, null, path, true, PathFormat.RelativePath); + return GetChangeTimeCore(transaction, null, false, path, true, PathFormat.RelativePath); } #endregion // GetChangeTimeUtc @@ -161,12 +161,13 @@ public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, /// The operating system is older than Windows Vista. /// The transaction. /// An open handle to the file or directory from which to retrieve information. + /// Specifies that is a file or directory. /// The file or directory for which to obtain creation date and time information. /// true gets the Coordinated Universal Time (UTC), false gets the local time. /// Indicates the format of the path parameter(s). [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Disposing is controlled.")] [SecurityCritical] - internal static DateTime GetChangeTimeCore(KernelTransaction transaction, SafeFileHandle safeFileHandle, string path, bool getUtc, PathFormat pathFormat) + internal static DateTime GetChangeTimeCore(KernelTransaction transaction, SafeFileHandle safeFileHandle, bool isFolder, string path, bool getUtc, PathFormat pathFormat) { if (!NativeMethods.IsAtLeastWindowsVista) throw new PlatformNotSupportedException(new Win32Exception((int) Win32Errors.ERROR_OLD_WIN_VERSION).Message); @@ -180,7 +181,7 @@ internal static DateTime GetChangeTimeCore(KernelTransaction transaction, SafeFi var pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.CheckInvalidPathChars); - safeFileHandle = CreateFileCore(transaction, false, pathLp, ExtendedFileAttributes.BackupSemantics, null, FileMode.Open, FileSystemRights.ReadData, FileShare.ReadWrite, true, false, PathFormat.LongFullPath); + safeFileHandle = CreateFileCore(transaction, isFolder, pathLp, ExtendedFileAttributes.BackupSemantics, null, FileMode.Open, FileSystemRights.ReadData, FileShare.ReadWrite, true, false, PathFormat.LongFullPath); } diff --git a/AlphaFS/Filesystem/FileInfo Class/FileInfo.EnumerateAlternateDataStreams.cs b/AlphaFS/Filesystem/FileInfo Class/FileInfo.EnumerateAlternateDataStreams.cs index a7abe3244..fa69440a9 100644 --- a/AlphaFS/Filesystem/FileInfo Class/FileInfo.EnumerateAlternateDataStreams.cs +++ b/AlphaFS/Filesystem/FileInfo Class/FileInfo.EnumerateAlternateDataStreams.cs @@ -31,7 +31,7 @@ partial class FileInfo [SecurityCritical] public IEnumerable EnumerateAlternateDataStreams() { - return File.EnumerateAlternateDataStreamsCore(Transaction, LongFullName, PathFormat.LongFullPath); + return File.EnumerateAlternateDataStreamsCore(Transaction, false, LongFullName, PathFormat.LongFullPath); } } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a52d98ef..336e1e103 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,15 @@ Changelog ========= -Version 2.2.4 (2018-XX-XX) +Version 2.2.4 (2018-07-12) ------------- ### Bugs Fixed - Issue #468: Method `Directory.CopyTimestamps` should throw `DirectoryNotFoundException`. - Issue #469: Method `Directory.GetFileIdInfo` should throw `DirectoryNotFoundException`. +- Issue #474: Method `Directory.EnumerateAlternateDataStreams` should throw `DirectoryNotFoundException`. +- Issue #476: Method `Directory.GetChangeTime` should throw `DirectoryNotFoundException`. Version 2.2.3 (2018-06-14)