create_dir
fn create_dir(string path) -> Result<unit, IoError> Import
Source: use io::fs::{create_dir}; compiler/src/builtin_docs/io/fs.hy Creates the directory path.
The parent must already exist (else Err(IoError::NotFound)), and
path must not (else Err(IoError::AlreadyExists)). Use
create_dir_all to create missing parents too.
Needs --allow-write.
Parameters#
| Name | Type |
|---|---|
path | string |
Returns#
Result<unit, IoError>
Examples#
use io::{IoError};
use io::fs::{create_dir, is_dir, remove_dir};
use tests::assert;
let dir = "/tmp/coil_doc_fs_create_dir";
let made = match create_dir(dir) {
Result::Ok(_) => true,
Result::Err(_) => false,
};
let again = match create_dir(dir) {
Result::Err(IoError::AlreadyExists) => true,
default => false,
};
let dir_now = match is_dir(dir) {
Result::Ok(b) => b,
Result::Err(_) => false,
};
let _ = remove_dir(dir);
assert!(made && again && dir_now);
See also#
io::fs::create_dir_allcopy: Copies the contents of filefromtoto, creating or overwritingto.exists: Returns whether anything exists atpath.is_dir: Returns whetherpathis a directory, following symbolic links.is_file: Returns whetherpathis a regular file, following symbolic links.is_symlink: Returns whetherpathitself is a symbolic link (the link is not followed).list_dir: Returns the names of the entries in directorypath, sorted.metadata: Returns facts aboutpathas a record, without following a final symbolic link.