Skip to content

Minor update on 'GetFileSystemItem' - #6984

Merged
Ilya (iSazonov) merged 1 commit into
PowerShell:masterfrom
daxian-dbw:attr
Jun 5, 2018
Merged

Ilya (iSazonov) merged 1 commit into
PowerShell:masterfrom
daxian-dbw:attr

Conversation

@daxian-dbw

@daxian-dbw Dongbo Wang (daxian-dbw) commented Jun 4, 2018 •

Copy link
Copy Markdown
Member

PR Summary

Submit minor updates to GetFileSystemItem.
I missed the review for #6909, and use this PR to address a few comments from myself :)

PR Checklist

@bergmeister Christoph Bergmeister (bergmeister) left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.
On a minor note: Would it not be more readable to determine if the file/directory exists as follows:

private static bool FileOrDirectoryExists(string path)
{
   return (Directory.Exists(path) || File.Exists(path));
}

Or is it a performance optimisation to just check the attributes instead?

@iSazonov Ilya (iSazonov) left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Dongbo Wang (@daxian-dbw) Thanks! Good catch!

Christoph Bergmeister (@bergmeister) Yes, the idea was to reduce kernel calls and extra path normalizations. Also we need process exceptions.

@iSazonov
Ilya (iSazonov) merged commit 0b32d0c into PowerShell:master Jun 5, 2018
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants