Function std::os::join_pathsExperimental [-]  [+] [src]

pub fn join_paths<T: BytesContainer>(paths: &[T]) -> Result<Vec<u8>, &'static str>

Joins a collection of Paths appropriately for the PATH environment variable.

Returns a Vec<u8> on success, since Paths are not utf-8 encoded on all platforms.

Returns an Err (containing an error message) if one of the input Paths contains an invalid character for constructing the PATH variable (a double quote on Windows or a colon on Unix).

Example

fn main() { use std::os; use std::path::Path; let key = "PATH"; let mut paths = os::getenv_as_bytes(key).map_or(Vec::new(), os::split_paths); paths.push(Path::new("/home/xyz/bin")); os::setenv(key, os::join_paths(paths.as_slice()).unwrap()); }
use std::os;
use std::path::Path;

let key = "PATH";
let mut paths = os::getenv_as_bytes(key).map_or(Vec::new(), os::split_paths);
paths.push(Path::new("/home/xyz/bin"));
os::setenv(key, os::join_paths(paths.as_slice()).unwrap());