#Manipulating Windows paths from Linux target?
13 messages · Page 1 of 1 (latest)
In the stdlib, the
PathBufuses whichever convention the target os uses.
It seems like you can do cross platform path manipulation with this just fine, looking at the docs ofpushandpopof it.
The PathBuf pushes forward slashes and pop misbehaves in Windows paths from Linux. For example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e82d0f3b6ebbbc4f8aee54d89696b2d9
A browser interface to the Rust compiler to experiment with the language
Are you able to just use / on windows?
yeah, it's the pop I'm more worried about
Wondering if there's any issue with replacing all \ with / before turning it into a PathBuf
tbh there probably isn't lol
that would work, although just a little janky
it would be helpful since I'm not sure the backslash won't break some stuff down the line
Do you know ahead of time what OS the path came from?
for context: my program is running on a Linux box which is talking to some other programs on a Windows box. The programs in Windows send me messages with windows paths in them, I translate that path to the same file share mounted in Linux to read some files. Then I write some files to the share. Then I talk again to the same programs on the same windows box telling them where I put files BUT from their perspective in windows-land. It's a real dumb way to do things, but it's out of my control
Do you control the program on the windows boxes? Can you just have them send pre-split paths?
that's what I suggested to my boss 😄
nope lol
I'm kinda leaning toward the straightforward replace method. You'll have to handle the drive letter but I'm guessing you already have that covered. Second best would be a crate.