createDir is now callable at compile time (#20824)
This commit is contained in:
parent
de89f6ce32
commit
32b145460f
1 changed files with 18 additions and 3 deletions
|
|
@ -26,7 +26,7 @@ when declared(math.signbit):
|
||||||
from std/envvars import getEnv, existsEnv, delEnv, putEnv, envPairs
|
from std/envvars import getEnv, existsEnv, delEnv, putEnv, envPairs
|
||||||
from std/os import getAppFilename
|
from std/os import getAppFilename
|
||||||
from std/private/oscommon import dirExists, fileExists
|
from std/private/oscommon import dirExists, fileExists
|
||||||
from std/private/osdirs import walkDir
|
from std/private/osdirs import walkDir, createDir
|
||||||
|
|
||||||
from std/times import cpuTime
|
from std/times import cpuTime
|
||||||
from std/hashes import hash
|
from std/hashes import hash
|
||||||
|
|
@ -49,6 +49,10 @@ template osop(op) {.dirty.} =
|
||||||
|
|
||||||
template oscommonop(op) {.dirty.} =
|
template oscommonop(op) {.dirty.} =
|
||||||
registerCallback(c, "stdlib.oscommon." & astToStr(op), `op Wrapper`)
|
registerCallback(c, "stdlib.oscommon." & astToStr(op), `op Wrapper`)
|
||||||
|
|
||||||
|
template osdirsop(op) {.dirty.} =
|
||||||
|
registerCallback(c, "stdlib.osdirs." & astToStr(op), `op Wrapper`)
|
||||||
|
|
||||||
template envvarsop(op) {.dirty.} =
|
template envvarsop(op) {.dirty.} =
|
||||||
registerCallback(c, "stdlib.envvars." & astToStr(op), `op Wrapper`)
|
registerCallback(c, "stdlib.envvars." & astToStr(op), `op Wrapper`)
|
||||||
|
|
||||||
|
|
@ -105,7 +109,17 @@ template wrap2svoid(op, modop) {.dirty.} =
|
||||||
op(getString(a, 0), getString(a, 1))
|
op(getString(a, 0), getString(a, 1))
|
||||||
modop op
|
modop op
|
||||||
|
|
||||||
template wrapDangerous(op, modop) {.dirty.} =
|
template wrapDangerous1svoid(op, modop) {.dirty.} =
|
||||||
|
if vmopsDanger notin c.config.features and (defined(nimsuggest) or c.config.cmd == cmdCheck):
|
||||||
|
proc `op Wrapper`(a: VmArgs) {.nimcall.} =
|
||||||
|
discard
|
||||||
|
modop op
|
||||||
|
else:
|
||||||
|
proc `op Wrapper`(a: VmArgs) {.nimcall.} =
|
||||||
|
op(getString(a, 0))
|
||||||
|
modop op
|
||||||
|
|
||||||
|
template wrapDangerous2svoid(op, modop) {.dirty.} =
|
||||||
if vmopsDanger notin c.config.features and (defined(nimsuggest) or c.config.cmd == cmdCheck):
|
if vmopsDanger notin c.config.features and (defined(nimsuggest) or c.config.cmd == cmdCheck):
|
||||||
proc `op Wrapper`(a: VmArgs) {.nimcall.} =
|
proc `op Wrapper`(a: VmArgs) {.nimcall.} =
|
||||||
discard
|
discard
|
||||||
|
|
@ -233,7 +247,8 @@ proc registerAdditionalOps*(c: PCtx) =
|
||||||
wrap1svoid(delEnv, envvarsop)
|
wrap1svoid(delEnv, envvarsop)
|
||||||
wrap1s(dirExists, oscommonop)
|
wrap1s(dirExists, oscommonop)
|
||||||
wrap1s(fileExists, oscommonop)
|
wrap1s(fileExists, oscommonop)
|
||||||
wrapDangerous(writeFile, ioop)
|
wrapDangerous2svoid(writeFile, ioop)
|
||||||
|
wrapDangerous1svoid(createDir, osdirsop)
|
||||||
wrap1s(readFile, ioop)
|
wrap1s(readFile, ioop)
|
||||||
wrap2si(readLines, ioop)
|
wrap2si(readLines, ioop)
|
||||||
systemop getCurrentExceptionMsg
|
systemop getCurrentExceptionMsg
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue