Closed MarijnS95 closed 4 years ago
Looks good, thanks!
@dvc94ch Thanks! I gave this another thought and can't realize a Rust world without standard separator conversion function, but Google-fu fails me. Are you perhaps aware of one?
EDIT: I guess that's why a crate exists for it... Oh joy :slightly_smiling_face:
@MarijnS95 I just submitted a PR which overlapped with this change. You might want to check for regressions as the PR replaced your path separator handling with glob.
@PrototypeNM1 From a very quick look their glob function uses std::path
as well and can hence not parse forward slashes correctly. I suggest to leave the replacement in place (since glob seems to expect a string instead of PathBuf
, replace /
with std::path::MAIN_SEPARATOR
) or at least test on Windows whether your patch does not introduce a regression.
I appreciate you pinging me but I am not on Windows while you seem to be; this should be trivial for you test?
I was testing on the following workspace on Windows...
[workspace]
members = ["crates/*", "crates/bevy_ecs/hecs"]
... so I believe it is working. If you have the motivating case I can pull and run I'd be happy to verify it still works.
@PrototypeNM1 The motivating case - an example even - is right in the commit and PR description.
The glob crate indeed splits on either separator and that only makes sense; it's not natural to write Windows specific code around glob()
with backslashes. That means this is working like it should.
Multilevel cargo workspace members are always written with a forward slash, for example:
On Windows forward slashes are not accepted at all, not even fs::canonicalize() is able to normalize them. Calling that function or trying to read a file from a path containing this string results in the following error:
Splitting the member name on a forward slash and constructing a new PathBuf from the parts seems the easiest to get a properly normalized path with the right separator for the platform.
Perhaps this line should be scoped by
#[cfg(windows)]
but I rather keep it generic. I initally expectedPathBuf
to have a.extend()
method accepting an iterator so that the result from.split()
can be shoved right in there, but alas. And folding over the result to recursively.join()
it to the path seems too verbose, so.collect
seems the simplest solution.