data fs
Namespace of directory operations.
Example:
use std.io { fs, File }
fn main() io {
let dir = fs.tempDir()!
File.writeText("{dir}/a.txt", "x")!
fs.createDir("{dir}/sub")!
for e in fs.list(dir)! {
print(e.name)
}
fs.removeAll(dir)!
}Вывод
a.txt sub
pub(api) data fsПотокобезопасность. the functions are independent; concurrent changes of one directory must coordinate themselves.
С версии. 1.0.0-beta
Методы
list | (path: str) -> List<DirEntry> | IoError ioEntries of a directory sorted by name (. |
walk | (path: str) -> List<DirEntry> | IoError ioAll descendants, sorted by relative path; symbolic links are listed, not followed. |
createDir | (path: str) -> () | IoError ioCreates one directory; fails with AlreadyExists if it exists and with NotFound if the parent is missing. |
createDirAll | (path: str) -> () | IoError ioCreates a directory and its missing parents; an existing directory is fine. |
removeDir | (path: str) -> () | IoError ioRemoves an empty directory. |
removeAll | (path: str) -> () | IoError ioRemoves a file or a whole directory tree (symbolic links are removed, not followed). |
realpath | (path: str) -> str | IoError ioAbsolute path with symbolic links and ./.. |
cwd | () -> str | IoError ioCurrent working directory. |
tempDir | (prefix: str) -> str | IoError ioA new empty private directory below $TMPDIR (default /tmp) named prefixXXXXXX; the caller removes it. |
Определено в: std/io/io.oxl:609