pub fn chdir() -> Result<()>Expand description
Change dir to / see chdir(2)
Upon successful completion, the current working directory is changed to /.
Otherwise, an error is returned with the system error code.
Example:
use fork::chdir;
use std::env;
match chdir() {
Ok(_) => {
let path = env::current_dir().expect("failed current_dir");
assert_eq!(Some("/"), path.to_str());
}
Err(e) => eprintln!("Failed to change directory: {}", e),
}ยงErrors
Returns an io::Error if the system call fails. Common errors include:
- Permission denied
- Path does not exist