Function in io::fs compiler

remove_dir

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

Removes the empty directory path.

Fails when the directory is not empty; use remove_dir_all for that. Needs --allow-write.

Parameters#

NameType
pathstring

Returns#

Result<unit, IoError>

Examples#

use io::fs::{create_dir, exists, remove_dir};
use tests::assert;
let dir = "/tmp/coil_doc_fs_remove_dir";
let _ = create_dir(dir);
let removed = match remove_dir(dir) {
    Result::Ok(_) => true,
    Result::Err(_) => false,
};
let left = match exists(dir) {
    Result::Ok(b) => b,
    Result::Err(_) => true,
};
assert!(removed && !left);

See also#

  • io::fs::remove_dir_all
  • 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).
↑ ↓ navigate ↵ open