-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Enable Get-ChildItem to produce Mode property even if cannot determine if hardlink
#7355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… not to be defined
0d6d779 to
5943c51
Compare
|
@SteveL-MSFT What will be the output after this change, will it exclude such files ? |
|
@kvprasoon no. With this change, it should work the same as with Windows PowerShell before we added the check for hard links. |
|
@kvprasoon It will not exclude such files. The mode for such files will not have |
|
@daxian-dbw Thanks for the clarification. |
iSazonov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one minor comment.
| } | ||
| } | ||
|
|
||
| return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could remove if-s:
bool succeeded = InternalSymbolicLinkLinkCodeMethods.GetFileInformationByHandle(handle, out handleInfo);
return succeeded && (handleInfo.NumberOfLinks > 1);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Will update.
|
@daxian-dbw FYI, I had to go back to the PR to figure this one out. The message used to commit wasn't as good as the PR title |
PR Summary
Some files in the user directory on Windows such as 'NTUSER.DAT' cause the IsHardLink() check to fail with an INVALID_HANDLE win32 error. This causes the
Modeproperty to fail being defined even though it was fine up until that last api call. I don't see any reason to throw an exception if the hard link check fails, instead just return false since we cannot determine it's a hardlink.Fix #7353
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests