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
11 changes: 1 addition & 10 deletions src/System.Management.Automation/CoreCLR/CorePsPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,6 @@ internal static bool NonWindowsIsHardLink(FileSystemInfo fileInfo)
return Unix.IsHardLink(fileInfo);
}

internal static bool NonWindowsIsSymLink(FileSystemInfo fileInfo)
{
return Unix.NativeMethods.IsSymLink(fileInfo.FullName);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we add a comment to the native code as to when this call was removed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I could but I don't understand why we need this - in last days we removed some P/Invokes
and earlier a few more without such comments. Perhaps it is more useful to open a tracking issue in PowerShell Native repo.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A tracking issue would work, but the issue is likely to be open for a long time.

}

internal static string NonWindowsInternalGetTarget(string path)
{
return Unix.NativeMethods.FollowSymLink(path);
Expand All @@ -492,7 +487,7 @@ internal static string NonWindowsGetUserFromPid(int path)

internal static string NonWindowsInternalGetLinkType(FileSystemInfo fileInfo)
{
if (NonWindowsIsSymLink(fileInfo))
if (fileInfo.Attributes.HasFlag(System.IO.FileAttributes.ReparsePoint))
{
return "SymbolicLink";
}
Expand Down Expand Up @@ -679,10 +674,6 @@ internal static class NativeMethods
[DllImport(psLib, CharSet = CharSet.Ansi, SetLastError = true)]
internal static extern int GetLinkCount([MarshalAs(UnmanagedType.LPStr)]string filePath, out int linkCount);

[DllImport(psLib, CharSet = CharSet.Ansi, SetLastError = true)]
[return: MarshalAs(UnmanagedType.I1)]
internal static extern bool IsSymLink([MarshalAs(UnmanagedType.LPStr)]string filePath);

[DllImport(psLib, CharSet = CharSet.Ansi, SetLastError = true)]
[return: MarshalAs(UnmanagedType.I1)]
internal static extern bool IsExecutable([MarshalAs(UnmanagedType.LPStr)]string filePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7987,9 +7987,7 @@ internal static bool IsHardLink(FileSystemInfo fileInfo)

internal static bool IsReparsePoint(FileSystemInfo fileInfo)
{
return Platform.IsWindows
? fileInfo.Attributes.HasFlag(System.IO.FileAttributes.ReparsePoint)
: Platform.NonWindowsIsSymLink(fileInfo);
return fileInfo.Attributes.HasFlag(System.IO.FileAttributes.ReparsePoint);
}

internal static bool WinIsHardLink(FileSystemInfo fileInfo)
Expand Down