Module Os

Operating system interfaces for paths, files, directories, standard streams, and environment variables.

Most operations return Result<Os.Error, ...>.

type Os.Error = String

Error type for OS operations (a human-readable message).

type Os.Path = iterative@append recursive@parent box choice {
  .absolute => Bytes,
  .append => [Bytes] self@append,
  .name => Bytes,
  .parent => Option<self@parent>,
  .parts => List<Bytes>,
}

A filesystem path value.

  • .name — get the file name component as bytes.
  • .absolute — get the absolute path as bytes.
  • .parts — get all path components as a list of byte sequences.
  • .parent — get the parent path, or .err! if at root.
  • .append(part) — return a path with one more path component.
dec Os.TraverseDir : [Os.Path] Result<Os.Error, recursive either {
  .dir (Os.Path, self) self,
  .end !,
  .file (Os.Path) self,
}>

Recursively traverses a directory tree, returning a nested structure of files and subdirectories sorted by name.

  • .end! — no more entries.
  • .file(path) rest — a file, followed by more entries.
  • .dir(path, children) rest — a subdirectory with its nested contents, followed by more entries.