Fix IsHardLink() to return false instead of throwing exception when unable to determine (#7355)

This commit is contained in:
Steve Lee
2018-07-26 10:08:38 -07:00
committed by Dongbo Wang
parent 20f7577548
commit b767d5cacd
2 changed files with 11 additions and 19 deletions
@@ -8111,19 +8111,7 @@ namespace Microsoft.PowerShell.Commands
{
BY_HANDLE_FILE_INFORMATION handleInfo;
bool succeeded = InternalSymbolicLinkLinkCodeMethods.GetFileInformationByHandle(handle, out handleInfo);
if (!succeeded)
{
int lastError = Marshal.GetLastWin32Error();
throw new Win32Exception(lastError);
}
if (handleInfo.NumberOfLinks > 1)
{
return true;
}
return false;
return succeeded && (handleInfo.NumberOfLinks > 1);
}
private static string InternalGetTarget(SafeFileHandle handle)