8000 Address Robert's feedbacks · PowerShell/PowerShell@b28f930 · GitHub
[go: up one dir, main page]

Skip to content

Commit b28f930

Browse files
committed
Address Robert's feedbacks
1 parent 3f06162 commit b28f930

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/System.Management.Automation/namespaces/FileSystemProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8280,7 +8280,7 @@ internal static bool IsReparsePointLikeSymlink(FileSystemInfo fileInfo)
82808280
fullPath = PathUtils.EnsureExtendedPrefix(fullPath);
82818281
}
82828282

8283-
using (var handle = FindFirstFileEx(fullPath, FINDEX_INFO_LEVELS.FindExInfoBasic, ref data, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, 0))
8283+
using (SafeFindHandle handle = FindFirstFileEx(fullPath, FINDEX_INFO_LEVELS.FindExInfoBasic, ref data, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, 0))
82848284
{
82858285
if (handle.IsInvalid)
82868286
{

src/System.Management.Automation/utils/PathUtils.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,18 @@ internal static bool TryDeleteFile(string filepath)
449449
return false;
450450
}
451451

452+
internal static string EnsureExtendedPrefix(string path)
453+
{
454+
if (IsPartiallyQualified(path) || IsDevice(path))
455+
return path;
456+
457+
// Given \\server\share in longpath becomes \\?\UNC\server\share
458+
if (path.StartsWith(UncPathPrefix, StringComparison.OrdinalIgnoreCase))
459+
return path.Insert(2, UncDevicePrefixToInsert);
460+
461+
return ExtendedDevicePathPrefix + path;
462+
}
463+
452464
#region Helpers for long paths from .Net RUmtime
453465
private const string ExtendedDevicePathPrefix = @"\\?\";
454466
private const string UncPathPrefix = @"\\";
@@ -467,18 +479,6 @@ private static bool IsValidDriveChar(char value)
467479
return ((value >= 'A' && value <= 'Z') || (value >= 'a' && value <= 'z'));
468480
}
469481

470-
internal static string EnsureExtendedPrefix(string path)
471-
{
472-
if (IsPartiallyQualified(path) || IsDevice(path))
473-
return path;
474-
475-
// Given \\server\share in longpath becomes \\?\UNC\server\share
476-
if (path.StartsWith(UncPathPrefix, StringComparison.OrdinalIgnoreCase))
477-
return path.Insert(2, UncDevicePrefixToInsert);
478-
479-
return ExtendedDevicePathPrefix + path;
480-
}
481-
482482
private static bool IsDevice(string path)
483483
{
484484
return IsExtended(path)

0 commit comments

Comments
 (0)
0