Function nix::unistd::mkdir[][src]

pub fn mkdir<P: ?Sized + NixPath>(path: &P, mode: Mode) -> Result<()>

Creates new directory path with access rights mode. (see mkdir(2))

Errors

There are several situations where mkdir might fail:

Example

extern crate tempfile;
extern crate nix;

use nix::unistd;
use nix::sys::stat;
use tempfile::tempdir;

fn main() {
    let tmp_dir1 = tempdir().unwrap();
    let tmp_dir2 = tmp_dir1.path().join("new_dir");

    // create new directory and give read, write and execute rights to the owner
    match unistd::mkdir(&tmp_dir2, stat::Mode::S_IRWXU) {
       Ok(_) => println!("created {:?}", tmp_dir2),
       Err(err) => println!("Error creating directory: {}", err),
    }
}