Nimony

The road to Nim 3

tempfiles

nimony/lib/std/tempfiles.nim

This module creates temporary files and directories.

The random part of a name comes from the operating system's CSPRNG (std/crypto/sysrand); only if that cannot be read does it fall back to a std/random generator seeded from the monotonic clock. Either way a name is never trusted to be unique: the file or directory is created exclusively (O_CREAT or O_EXCL / CREATE_NEW, mkdir) and a fresh name is drawn when it already exists.

Unlike Nim's std/tempfiles, which takes and returns string, the directory and the returned paths are Path, matching std/files and std/dirs (so removeDir(createTempDir(...)) just works).

See also: