Module fs/temp

fs/temp

RAII-managed temporary files and directories.

Example

{ TempDir } :: import "std/fs/temp";

main :: (fn(io : Io, exn : Exception) -> unit)({
  dir := io.await(TempDir.new(io), { io, exn });
  println(dir.path());
  io.await(dir.remove(io), { io, exn });
});

Types

TempDir object
TempDir

Temporary directory that can be cleaned up with remove.

Fields

NameTypeDescription
_pathPath
_removedbool
impl(TempDir, ...)
new_in : (TempDir) fn(parent : Path, io : Io) -> Impl(Future(TempDir, IoExn))

Parameters

NameTypeNotes
parentPath
ioIo

Returns: Impl(Future(TempDir, IoExn))

new : (TempDir) fn(io : Io) -> Impl(Future(TempDir, IoExn))

Parameters

NameTypeNotes
ioIo

Returns: Impl(Future(TempDir, IoExn))

path : (TempDir) fn(self : TempDir) -> Path

Parameters

NameTypeNotes
selfTempDir

Returns: Path

remove : (TempDir) fn(self : TempDir, io : Io) -> Impl(Future(unit, IoExn))

Parameters

NameTypeNotes
selfTempDir
ioIo

Returns: Impl(Future(unit, IoExn))

TempFile object
TempFile

Temporary file backed by a File handle.

Fields

NameTypeDescription
_fileFile
_pathPath
_removedbool
impl(TempFile, ...)
new_in : (TempFile) fn(parent : Path, io : Io) -> Impl(Future(TempFile, IoExn))

Parameters

NameTypeNotes
parentPath
ioIo

Returns: Impl(Future(TempFile, IoExn))

new : (TempFile) fn(io : Io) -> Impl(Future(TempFile, IoExn))

Parameters

NameTypeNotes
ioIo

Returns: Impl(Future(TempFile, IoExn))

file : (TempFile) fn(self : TempFile) -> File

Parameters

NameTypeNotes
selfTempFile

Returns: File

path : (TempFile) fn(self : TempFile) -> Path

Parameters

NameTypeNotes
selfTempFile

Returns: Path

remove : (TempFile) fn(self : TempFile, io : Io) -> Impl(Future(unit, IoExn))

Parameters

NameTypeNotes
selfTempFile
ioIo

Returns: Impl(Future(unit, IoExn))