From 5f1e144de965d10b61fbd2c8e3ac50c12099690a Mon Sep 17 00:00:00 2001 From: Philipp Keller Date: Wed, 7 Sep 2016 07:17:36 +0200 Subject: resolving all remarks by @posborne, fixed max line length=99, fixed rust 1.2.0 error in doc-test --- src/unistd.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src') 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(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(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(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 { -- cgit v1.2.3