remove_dir
fn remove_dir(string path) -> Result<unit, IoError> Import
Source: use io::fs::{remove_dir}; 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#
| Name | Type |
|---|---|
path | string |
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_allcopy: Copies the contents of filefromtoto, creating or overwritingto.create_dir: Creates the directorypath.create_dir_all: Creates the directorypathand any missing parent directories.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).