Replies: 1 comment
-
RE simpler - Also, don't forget about wildcard handling, which might necessitate a LiteralPath parameter. And how to make these parameters pipeline bound (via the alias PSPath). This should also cover recommend error handling practices for when path doesn't exist (and must) or the path is not a valid path, etc. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Given you're accepting a
$Path
parameter in your function...I think there are 4 scenarios, which are the flip sides of two conditions:
Condition One: Does it need to already exist?
Condition Two: Do you care about the provider?
Have I missed any scenarios?
By far the hardest of these to deal with (I think) is when the path may not exist yet, and it has to be a specific provider. For instance, if you want to take a relative or absolute path to a file and pass it to $xml.Save($path)
If the path is relative, you must convert it to a full path, because
[Environment]::CurrentDirectory
might as well be randomized. Otherwise, you could probably leave it alone. But assuming it might be relative, and assuming your script might be called while$pwd
is in a non-filesystem folder ... what do you do?Does this work? Is there something simpler?
Beta Was this translation helpful? Give feedback.
All reactions