close #9372 add std/tempfiles (#17361)

* close #9372 add std/tempfile
This commit is contained in:
flywind 2021-04-21 21:07:36 +08:00 • committed by GitHub
commit c631648cb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 159 additions and 0 deletions

View file

@ -0,0 +1,17 @@
import std/[os, tempfiles]
doAssert createTempDir("nim", "tmp") != createTempDir("nim", "tmp")
block:
var t1 = createTempFile("nim", ".tmp")
var t2 = createTempFile("nim", ".tmp")
doAssert t1.path != t2.path
write(t1.fd, "1234")
doAssert readAll(t2.fd) == ""
close(t1.fd)
close(t2.fd)
removeFile(t1.path)
removeFile(t2.path)