juozhe
June 10, 2024, 6:02pm
1
Linux and Windows often gather several directory names together.
Linux uses colon ":" as separator and Windows uses semicolon ";".
Is there any variable or function in the library that can be
used for separating directories from the whole string?
Example directory names together:
"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
"C:\\WINDOWS\\system32;C:\\WINDOWS"
There is a similar variable std::path::MAIN_SEPARATOR
that returns the separator within the directory names.
jofas
June 10, 2024, 6:14pm
2
juozhe
June 10, 2024, 6:31pm
3
No, this won't work, MAIN_SEPARATOR is either slash or backslash
/// The primary separator of path components for the current platform.
/// For example, `/` on Unix and `\` on Windows.
I'm looking for someting that's either colon or semicolon.
You might be looking for std::env::split_paths
5 Likes
system
Closed
September 8, 2024, 6:48pm
5
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.