summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Keller <philipp.keller@gmail.com>2016-09-07 07:17:36 +0200
committerPhilipp Keller <philipp.keller@gmail.com>2016-09-07 07:17:36 +0200
commit5f1e144de965d10b61fbd2c8e3ac50c12099690a (patch)
tree8ae793fca97f843bb92c1b3aefadf0c8d624bc43 /src
parent37e4f9756d7181e6b95f9b812874d582bfc2eec5 (diff)
downloadnix-5f1e144de965d10b61fbd2c8e3ac50c12099690a.zip
resolving all remarks by @posborne, fixed max line length=99, fixed rust 1.2.0 error in doc-test
Diffstat (limited to 'src')
-rw-r--r--src/unistd.rs22
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> {