OxL Справочник OxL
РусскийEnglish

data fs

Namespace of directory operations.

Example:

oxl✓ проверяется в CI
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 io
Entries of a directory sorted by name (.
walk(path: str) -> List<DirEntry> | IoError io
All descendants, sorted by relative path; symbolic links are listed, not followed.
createDir(path: str) -> () | IoError io
Creates one directory; fails with AlreadyExists if it exists and with NotFound if the parent is missing.
createDirAll(path: str) -> () | IoError io
Creates a directory and its missing parents; an existing directory is fine.
removeDir(path: str) -> () | IoError io
Removes an empty directory.
removeAll(path: str) -> () | IoError io
Removes a file or a whole directory tree (symbolic links are removed, not followed).
realpath(path: str) -> str | IoError io
Absolute path with symbolic links and ./..
cwd() -> str | IoError io
Current working directory.
tempDir(prefix: str) -> str | IoError io
A new empty private directory below $TMPDIR (default /tmp) named prefixXXXXXX; the caller removes it.

Определено в: std/io/io.oxl:609

См. также