diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/unistd.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/unistd.rs b/src/unistd.rs index d7bd3b91..74d74c9c 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -5,7 +5,7 @@ use fcntl::{fcntl, OFlag, O_NONBLOCK, O_CLOEXEC, FD_CLOEXEC}; use fcntl::FcntlArg::{F_SETFD, F_SETFL}; use libc::{self, c_char, c_void, c_int, c_uint, size_t, pid_t, off_t, uid_t, gid_t, mode_t}; use std::mem; -use std::ffi::{CString,CStr,OsString}; +use std::ffi::{CString, CStr, OsString}; use std::os::unix::ffi::OsStringExt; use std::path::PathBuf; use std::os::unix::io::RawFd; @@ -118,13 +118,15 @@ pub fn chdir<P: ?Sized + NixPath>(path: &P) -> Result<()> { /// /// # Errors /// -/// `Err` is returned in case of an error. There are several situations where mkdir might fail. -/// For a full list consult `man mkdir(2)` +/// There are several situations where mkdir might fail: /// /// - current user has insufficient rights in the parent directory /// - the path already exists /// - the path name is too long (longer than `PATH_MAX`, usually 4096 on linux, 1024 on OS X) /// +/// For a full list consult +/// [man mkdir(2)](http://man7.org/linux/man-pages/man2/mkdir.2.html#ERRORS) +/// /// # Example /// /// ```rust @@ -141,7 +143,7 @@ pub fn chdir<P: ?Sized + NixPath>(path: &P) -> Result<()> { /// /// // create new directory and give read, write and execute rights to the owner /// match unistd::mkdir(&tmp_dir, stat::S_IRWXU) { -/// Ok(_) => println!("created {:?}", tmp_dir.display()), +/// Ok(_) => println!("created {:?}", tmp_dir), /// Err(err) => println!("Error creating directory: {}", err), /// } /// } @@ -157,15 +159,21 @@ pub fn mkdir<P: ?Sized + NixPath>(path: &P, mode: Mode) -> Result<()> { /// Returns the current directory as a PathBuf /// -/// Err is returned if the current user doesn't have the permission to read or search a component of the current path. +/// Err is returned if the current user doesn't have the permission to read or search a component +/// of the current path. /// /// # Example /// /// ```rust +/// extern crate nix; +/// /// use nix::unistd; /// -/// let dir = unistd::getcwd().expect("not allowed to get current directory"); -/// println!("The current directory is {:?}", dir.display()); +/// fn main() { +/// // assume that we are allowed to get current directory +/// let dir = unistd::getcwd().unwrap(); +/// println!("The current directory is {:?}", dir); +/// } /// ``` #[inline] pub fn getcwd() -> Result<PathBuf> { |