(Very similar question, excluding CWD support: How to check whether a path exists?)
I want to check whether a file-system paths parent directory - given as string - exists, also if that parent is the CWD, indicated as "".
In my specific case, I get a local file path as CLI argument,
that points to the output/result file of my software.
The file does not have to exist, but it's parent dir has to exist,
which I check with Path::new(out_file).parent()?.exists()
.
If out_file
is for example "out.txt"
, it's parent will be ""
,
Which will always return false
for the exists()
call,
because Rust does not interpret Path::new("")
as CWD.