Remove Utils.FileExists(), Utils.DirectoryExists() and Utils.ItemExists() methods#7100
Remove Utils.FileExists(), Utils.DirectoryExists() and Utils.ItemExists() methods#7100iSazonov wants to merge 27 commits intoPowerShell:masterfrom
Conversation
There was a problem hiding this comment.
return was within the catch block.
There was a problem hiding this comment.
@adityapatwardhan Could you please clarify why we should move the return in catch block to continue recursion removal?
Previous code was trying the recursion removal if only we can not remove reparse point silently without any error and exception - is it real scenario?
|
@iSazonov Please have a look at the test failures. |
4b63525 to
a0acbd0
Compare
|
Rebased to get latest fixes. |
a0acbd0 to
68d9f25
Compare
68d9f25 to
2d28133
Compare
Exclude GetFileSystemInfo() and Utils.FileExists()
e629b77 to
132ef5e
Compare
File.Exists and Directory.Exists return false for device names so we can not call IsReservedDeviceName(path)
132ef5e to
0172040
Compare
|
I update some commits:
Seems I fixed all Appveyor CI issues. I can not build Unix version locally so I haven't a progress with Travis CI issues. |
| FileSystemInfo fsinfo = new FileInfo(path); | ||
| var attr = fsinfo.Attributes; | ||
| var exists = (int)attr != -1; | ||
| isContainer = exists && attr.HasFlag(FileAttributes.Directory); |
There was a problem hiding this comment.
I see code like this for checking if a path exists and whether it's directory at 8 places. I think keeping the redundant code in Utils.ItemExists is better. Thoughts?
There was a problem hiding this comment.
I agree. I was hoping to remove "unnecessary" checks of existence at all but it's too complicated the PR. I suppose the correct approach is that an operation is performed and an exception is handled instead of up to 6 times to check for each file's existence.
I think I'll close the PR and open new one where add commit by commit to discover and fix Unix issues and replace ItemExists with CheckItemExistsAndThrowOnError .
|
Continue in #7129 |
PR Summary
Continue #6929
Cleanup code to replace Utils.FileExists(), Utils.DirectoryExists() and Utils.ItemExists() methods with .Net Core methods.
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