Function in io::fs compiler

remove_dir_all

fn remove_dir_all(string path) -> Result<unit, IoError>
Import
use io::fs::{remove_dir_all};
Source: compiler/src/builtin_docs/io/fs.hy

Removes the directory path and everything inside it.

Symbolic links inside are removed, not followed. Returns Err(IoError::NotFound) when path does not exist. Needs --allow-write.

Parameters#

NameType
pathstring

Returns#

Result<unit, IoError>

Examples#

use io::fs::{create_dir_all, exists, remove_dir_all};
use io::file::{write_text};
use tests::assert;
let _ = create_dir_all("/tmp/coil_doc_fs_rda/x/y");
let _ = write_text("/tmp/coil_doc_fs_rda/x/y/f.txt", "z");
let removed = match remove_dir_all("/tmp/coil_doc_fs_rda") {
    Result::Ok(_) => true,
    Result::Err(_) => false,
};
let left = match exists("/tmp/coil_doc_fs_rda") {
    Result::Ok(b) => b,
    Result::Err(_) => true,
};
assert!(removed && !left);

See also#

  • copy: Copies the contents of file from to to, creating or overwriting to.
  • create_dir: Creates the directory path.
  • create_dir_all: Creates the directory path and any missing parent directories.
  • 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.
↑ ↓ navigate ↵ open