Types
TemporaryDirectoryWrapper = object name*: string
- Source Edit
TemporaryFileCloser[IO] = ref object file*: IO name*: string
- Source Edit
TemporaryFileWrapper[IO] = object
- Source Edit
Procs
proc `=destroy`(self: var TemporaryDirectoryWrapper) {....raises: [], tags: [WriteDirEffect, ReadDirEffect], forbids: [].}
- Source Edit
proc cleanup(self: TemporaryDirectoryWrapper) {....raises: [Exception], tags: [WriteDirEffect, ReadDirEffect], forbids: [].}
- Source Edit
proc close(self: TemporaryDirectoryWrapper) {....raises: [], tags: [WriteDirEffect, ReadDirEffect], forbids: [].}
- used to be called in with stmt (Python's doesn't have this) Source Edit
proc close(t: TemporaryFileWrapper)
- Source Edit
proc close[IO](self: TemporaryFileCloser[IO]; unlink = os.removeFile)
- Source Edit
proc flush[IO](self: TemporaryFileWrapper[IO])
- Source Edit
proc TemporaryDirectory(suffix = sNone; prefix = sNone; dir = sNone; ignore_cleanup_errors = False; delete = True): TemporaryDirectoryWrapper {. ...raises: [OSError, IOError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteDirEffect], forbids: [].}
-
Example:
import std/os let d = TemporaryDirectory() assert dirExists d.name d.cleanup() assert not dirExists d.name
Source Edit
Templates
template name(self: TemporaryFileWrapper): string
- Source Edit
template NamedTemporaryFile(mode: static[string | char] = "w+b"; buffering = -1; encoding = DefEncoding; newline = DefNewLine; suffix = sNone; prefix = sNone; dir = sNone; delete = True; errors = DefErrors): TemporaryFileWrapper
-
Example:
var tempf = NamedTemporaryFile("w+t") let msg = "test" tempf.write(msg) tempf.flush() tempf.seek(0) let s = tempf.read() assert s == msg import std/os assert fileExists tempf.name tempf.close() assert not fileExists tempf.name
Source Edit template read[IO](self: TemporaryFileWrapper[IO]; args`gensym5: varargs[typed]): untyped
- Source Edit
template readline[IO](self: TemporaryFileWrapper[IO]; args`gensym6: varargs[typed]): untyped
- Source Edit
template seek[IO](self: TemporaryFileWrapper[IO]; args`gensym7: varargs[typed]): untyped
- Source Edit
template tell[IO](self: TemporaryFileWrapper[IO]; args`gensym8: varargs[typed]): untyped
- Source Edit
template write[IO](self: TemporaryFileWrapper[IO]; args`gensym4: varargs[typed]): untyped
- Source Edit