Function in io::fs compiler

create_dir_all

fn create_dir_all(string path) -> Result<unit, IoError>
Import
use io::fs::{create_dir_all};
Source: 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#

NameType
pathstring

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 file from to to, creating or overwriting to.
  • create_dir: Creates the directory path.
  • exists: Returns whether anything exists at path.
  • is_dir: Returns whether path is a directory, following symbolic links.
  • is_file: Returns whether path is a regular file, following symbolic links.
  • is_symlink: Returns whether path itself is a symbolic link (the link is not followed).
  • list_dir: Returns the names of the entries in directory path, sorted.
  • metadata: Returns facts about path as a record, without following a final symbolic link.
↑ ↓ navigate ↵ open