remove_file
fn remove_file(string path) -> Result<unit, IoError> Import
Source: use io::fs::{remove_file}; compiler/src/builtin_docs/io/fs.hy Removes the file (or symbolic link) at path.
A symbolic link is removed itself, not its target. Returns
Err(IoError::NotFound) when nothing is there.
Needs --allow-write.
Parameters#
| Name | Type |
|---|---|
path | string |
Returns#
Result<unit, IoError>
Examples#
use io::{IoError};
use io::fs::{remove_file};
use io::file::{write_text};
use tests::assert;
let path = "/tmp/coil_doc_fs_remove_file.txt";
let _ = write_text(path, "x");
let removed = match remove_file(path) {
Result::Ok(_) => true,
Result::Err(_) => false,
};
let again = match remove_file(path) {
Result::Err(IoError::NotFound) => true,
default => false,
};
assert!(removed && again);
See also#
copy: 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).list_dir: Returns the names of the entries in directorypath, sorted.