devela::_dep::nc::call

Function getcwd

pub unsafe fn getcwd(buf: &mut [u8]) -> Result<isize, i32> 
Available on crate feature dep_nc only.
Expand description

Get current working directory.

§Examples

let mut buf = [0_u8; nc::PATH_MAX as usize + 1];
let ret = unsafe { nc::getcwd(&mut buf) };
assert!(ret.is_ok());
// Remove null-terminal char.
let path_len = ret.unwrap() as usize - 1;
let cwd = std::str::from_utf8(&buf[..path_len]);
assert!(cwd.is_ok());