Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/System.Management.Automation/CoreCLR/CorePsPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,6 @@ internal static bool NonWindowsIsSymLink(FileSystemInfo fileInfo)
return Unix.NativeMethods.IsSymLink(fileInfo.FullName);
}

internal static string NonWindowsInternalGetTarget(SafeFileHandle handle)
{
// SafeHandle is a Windows concept. Use the string version instead.
throw new PlatformNotSupportedException();
}

internal static string NonWindowsInternalGetTarget(string path)
{
return Unix.NativeMethods.FollowSymLink(path);
Expand Down
34 changes: 10 additions & 24 deletions src/System.Management.Automation/namespaces/FileSystemProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7618,25 +7618,23 @@ internal static extern IntPtr CreateFile(
/// <returns>The target of the reparse point</returns>
public static IEnumerable<string> GetTarget(PSObject instance)
{
FileSystemInfo fileSysInfo = instance.BaseObject as FileSystemInfo;

if (fileSysInfo != null)
if (instance.BaseObject is FileSystemInfo fileSysInfo)
{
if (Platform.IsWindows)
#if !UNIX
using (SafeFileHandle handle = OpenReparsePoint(fileSysInfo.FullName, FileDesiredAccess.GenericRead))
{
using (SafeFileHandle handle = OpenReparsePoint(fileSysInfo.FullName, FileDesiredAccess.GenericRead))
{
string linkTarget = InternalGetTarget(handle);
string linkTarget = WinInternalGetTarget(handle);

if (linkTarget != null)
return (new string[] { linkTarget });
if (linkTarget != null)
{
return (new string[] { linkTarget });
}
}

#endif
return InternalGetTarget(fileSysInfo.FullName);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the definition for this method is gone but a call remains. Is there another definition somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, one - wih handle parameter, second with string parameter. First one was removed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking 😄

}
else
return null;

return null;
}

/// <summary>
Expand Down Expand Up @@ -7964,18 +7962,6 @@ internal static bool WinIsHardLink(ref IntPtr handle)
return succeeded && (handleInfo.NumberOfLinks > 1);
}

private static string InternalGetTarget(SafeFileHandle handle)
{
if (Platform.IsWindows)
{
return WinInternalGetTarget(handle);
}
else
{
return Platform.NonWindowsInternalGetTarget(handle);
}
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods")]
private static string WinInternalGetTarget(SafeFileHandle handle)
{
Expand Down