Separator between directory names

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.

str::split with std::path::MAIN_SEPARATOR?

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

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.