Function nix::unistd::mkdir
[−]
[src]
pub fn mkdir<P: ?Sized + NixPath>(path: &P, mode: Mode) -> Result<()>
Creates new directory path
with access rights mode
.
Errors
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)
Example
extern crate tempdir; extern crate nix; use nix::unistd; use nix::sys::stat; use tempdir::TempDir; fn main() { let mut tmp_dir = TempDir::new("test_mkdir").unwrap().into_path(); tmp_dir.push("new_dir"); // 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), Err(err) => println!("Error creating directory: {}", err), } }