create_dir_all
fn create_dir_all(string path) -> Result<unit, IoError> Import
Source: use io::fs::{create_dir_all}; compiler/src/builtin_docs/io/fs.hy Creates the directory path and any missing parent directories.
Succeeds when path already exists as a directory.
Needs --allow-write.
Parameters#
| Name | Type |
|---|---|
path | string |
Returns#
Result<unit, IoError>
Examples#
use io::fs::{create_dir_all, is_dir, remove_dir_all};
use tests::assert;
let made = match create_dir_all("/tmp/coil_doc_fs_cda/a/b/c") {
Result::Ok(_) => true,
Result::Err(_) => false,
};
let dir_now = match is_dir("/tmp/coil_doc_fs_cda/a/b/c") {
Result::Ok(b) => b,
Result::Err(_) => false,
};
let _ = remove_dir_all("/tmp/coil_doc_fs_cda");
assert!(made && dir_now);
See also#
copy: Copies the contents of filefromtoto, creating or overwritingto.create_dir: Creates the directorypath.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.