★ wanayoo — archive 1999 https://github.com/PowerShell/PowerShell/pull/8025Nouvelle recherche | Portail wanayoo
Skip to content
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

Add a path for checking ZoneInformation without throwing an exception #8025

Merged
merged 5 commits into from Oct 24, 2018

Conversation

Projects
None yet
4 participants
@powercode
Copy link
Collaborator

commented Oct 14, 2018 •

PR Summary

In an effort to reduce the number of exceptions we throw as standard flowcontrol, this PR adds

bool TryCreateFileStream(
    string path,
    string streamName, 
    FileMode mode, 
    FileAccess access, 
    FileShare share,  
   out FileStream stream) 

as a non-throwing alternative to CreateFileStream.

This makes the code slightly faster and debugging slightly less annoying.

PR Checklist

@powercode powercode requested review from anmenaga and BrucePay as code owners Oct 14, 2018

{
string errorMessage = StringUtil.Format(
FileSystemProviderStrings.AlternateDataStreamNotFound, streamName, path);
throw new FileNotFoundException(errorMessage, resultPath);
throw new FileNotFoundException(errorMessage, $"{path}:{streamName.Trim()}");

This comment has been minimized.

Copy link
@iSazonov

iSazonov Oct 16, 2018

Collaborator

Do we really need Trim() for streamName in the internal methods? We do not this for path.

This comment has been minimized.

Copy link
@powercode

powercode Oct 16, 2018

Author Collaborator

Not sure - I just opted to not change any functionality. Small cost on the error path.

This comment has been minimized.

Copy link
@iSazonov

iSazonov Oct 16, 2018

Collaborator

I vote to remove - I believe consumer should take care.

iSazonov added some commits Oct 17, 2018

@iSazonov iSazonov self-assigned this Oct 23, 2018

@iSazonov iSazonov merged commit 3e4fa87 into PowerShell:master Oct 24, 2018

8 checks passed

CodeFactor 6 issues fixed.
Details
PowerShell-CI-linux #PR-8025-20181018.01 succeeded
Details
PowerShell-CI-macos #PR-8025-20181018.01 succeeded
Details
PowerShell-CI-spelling #4139 succeeded
Details
PowerShell-CI-windows #PR-8025-20181018.01 succeeded
Details
WIP ready for review
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
license/cla All CLA requirements met.
Details
@TravisEz13
Copy link
Member

left a comment

LGTM

adityapatwardhan pushed a commit to adityapatwardhan/PowerShell that referenced this pull request Apr 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.