parent
64995db4fd
commit
bbc231f8e0
2 changed files with 17 additions and 9 deletions
|
|
@ -57,9 +57,9 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
|
||||||
|
|
||||||
# Idea: Treat link to file as a file, but ignore link to directory to prevent
|
# Idea: Treat link to file as a file, but ignore link to directory to prevent
|
||||||
# endless recursions out of the box.
|
# endless recursions out of the box.
|
||||||
cbos listFiles:
|
cbos listFilesImpl:
|
||||||
listDirs(a, {pcFile, pcLinkToFile})
|
listDirs(a, {pcFile, pcLinkToFile})
|
||||||
cbos listDirs:
|
cbos listDirsImpl:
|
||||||
listDirs(a, {pcDir})
|
listDirs(a, {pcDir})
|
||||||
cbos removeDir:
|
cbos removeDir:
|
||||||
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
|
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,10 @@ template builtin = discard
|
||||||
# We know the effects better than the compiler:
|
# We know the effects better than the compiler:
|
||||||
{.push hint[XDeclaredButNotUsed]: off.}
|
{.push hint[XDeclaredButNotUsed]: off.}
|
||||||
|
|
||||||
proc listDirs*(dir: string): seq[string] =
|
proc listDirsImpl(dir: string): seq[string] {.
|
||||||
## Lists all the subdirectories (non-recursively) in the directory `dir`.
|
tags: [ReadIOEffect], raises: [OSError].} = builtin
|
||||||
builtin
|
proc listFilesImpl(dir: string): seq[string] {.
|
||||||
proc listFiles*(dir: string): seq[string] =
|
tags: [ReadIOEffect], raises: [OSError].} = builtin
|
||||||
## Lists all the files (non-recursively) in the directory `dir`.
|
|
||||||
builtin
|
|
||||||
|
|
||||||
proc removeDir(dir: string) {.
|
proc removeDir(dir: string) {.
|
||||||
tags: [ReadIOEffect, WriteIOEffect], raises: [OSError].} = builtin
|
tags: [ReadIOEffect, WriteIOEffect], raises: [OSError].} = builtin
|
||||||
proc removeFile(dir: string) {.
|
proc removeFile(dir: string) {.
|
||||||
|
|
@ -47,6 +44,7 @@ proc copyDir(src, dest: string) {.
|
||||||
tags: [ReadIOEffect, WriteIOEffect], raises: [OSError].} = builtin
|
tags: [ReadIOEffect, WriteIOEffect], raises: [OSError].} = builtin
|
||||||
proc createDir(dir: string) {.tags: [WriteIOEffect], raises: [OSError].} =
|
proc createDir(dir: string) {.tags: [WriteIOEffect], raises: [OSError].} =
|
||||||
builtin
|
builtin
|
||||||
|
|
||||||
proc getError: string = builtin
|
proc getError: string = builtin
|
||||||
proc setCurrentDir(dir: string) = builtin
|
proc setCurrentDir(dir: string) = builtin
|
||||||
proc getCurrentDir*(): string =
|
proc getCurrentDir*(): string =
|
||||||
|
|
@ -196,6 +194,16 @@ template log(msg: string, body: untyped) =
|
||||||
if mode != ScriptMode.WhatIf:
|
if mode != ScriptMode.WhatIf:
|
||||||
body
|
body
|
||||||
|
|
||||||
|
proc listDirs*(dir: string): seq[string] =
|
||||||
|
## Lists all the subdirectories (non-recursively) in the directory `dir`.
|
||||||
|
result = listDirsImpl(dir)
|
||||||
|
checkOsError()
|
||||||
|
|
||||||
|
proc listFiles*(dir: string): seq[string] =
|
||||||
|
## Lists all the files (non-recursively) in the directory `dir`.
|
||||||
|
result = listFilesImpl(dir)
|
||||||
|
checkOsError()
|
||||||
|
|
||||||
proc rmDir*(dir: string) {.raises: [OSError].} =
|
proc rmDir*(dir: string) {.raises: [OSError].} =
|
||||||
## Removes the directory `dir`.
|
## Removes the directory `dir`.
|
||||||
log "rmDir: " & dir:
|
log "rmDir: " & dir:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue