parent
2aeac26f08
commit
7577ea9e4c
1 changed files with 6 additions and 5 deletions
|
|
@ -122,8 +122,9 @@ proc getTempDirImpl(dir: string): string {.inline.} =
|
||||||
proc genTempPath*(prefix, suffix: string, dir = ""): string =
|
proc genTempPath*(prefix, suffix: string, dir = ""): string =
|
||||||
## Generates a path name in `dir`.
|
## Generates a path name in `dir`.
|
||||||
##
|
##
|
||||||
## If `dir` is empty, (`getTempDir <os.html#getTempDir>`_) will be used.
|
|
||||||
## The path begins with `prefix` and ends with `suffix`.
|
## The path begins with `prefix` and ends with `suffix`.
|
||||||
|
##
|
||||||
|
## .. note:: `dir` must exist (empty `dir` will resolve to `getTempDir <os.html#getTempDir>`_).
|
||||||
let dir = getTempDirImpl(dir)
|
let dir = getTempDirImpl(dir)
|
||||||
result = dir / (prefix & randomPathName(nimTempPathLength) & suffix)
|
result = dir / (prefix & randomPathName(nimTempPathLength) & suffix)
|
||||||
|
|
||||||
|
|
@ -138,7 +139,7 @@ proc createTempFile*(prefix, suffix: string, dir = ""): tuple[cfile: File, path:
|
||||||
##
|
##
|
||||||
## .. note:: It is the caller's responsibility to close `result.cfile` and
|
## .. note:: It is the caller's responsibility to close `result.cfile` and
|
||||||
## remove `result.file` when no longer needed.
|
## remove `result.file` when no longer needed.
|
||||||
## .. note:: `dir` must exist (empty `dir` will resolve to `getTempDir()`).
|
## .. note:: `dir` must exist (empty `dir` will resolve to `getTempDir <os.html#getTempDir>`_).
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
import std/os
|
import std/os
|
||||||
doAssertRaises(OSError): discard createTempFile("", "", "nonexistent")
|
doAssertRaises(OSError): discard createTempFile("", "", "nonexistent")
|
||||||
|
|
@ -170,7 +171,7 @@ proc createTempDir*(prefix, suffix: string, dir = ""): string =
|
||||||
## If failing to create a temporary directory, `OSError` will be raised.
|
## If failing to create a temporary directory, `OSError` will be raised.
|
||||||
##
|
##
|
||||||
## .. note:: It is the caller's responsibility to remove the directory when no longer needed.
|
## .. note:: It is the caller's responsibility to remove the directory when no longer needed.
|
||||||
## .. note:: `dir` must exist (empty `dir` will resolve to `getTempDir()`).
|
## .. note:: `dir` must exist (empty `dir` will resolve to `getTempDir <os.html#getTempDir>`_).
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
import std/os
|
import std/os
|
||||||
doAssertRaises(OSError): discard createTempDir("", "", "nonexistent")
|
doAssertRaises(OSError): discard createTempDir("", "", "nonexistent")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue