diff options
author | genotrance <dev@genotrance.com> | 2020-03-12 02:53:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-12 08:53:11 +0100 |
commit | bbc231f8e06c18fe640fa56a927df476c2426ccb (patch) | |
tree | 39cf9161ebb0abba48cc82d8d28f979cece8a183 /lib | |
parent | 64995db4fdc8d39a9d9c7a1bfb5d8e1dd8c0f902 (diff) | |
download | Nim-bbc231f8e06c18fe640fa56a927df476c2426ccb.tar.gz |
Fix #12676 (#13634)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system/nimscript.nim | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/system/nimscript.nim b/lib/system/nimscript.nim index 719e92c4a..b8abdaa38 100644 --- a/lib/system/nimscript.nim +++ b/lib/system/nimscript.nim @@ -26,13 +26,10 @@ template builtin = discard # We know the effects better than the compiler: {.push hint[XDeclaredButNotUsed]: off.} -proc listDirs*(dir: string): seq[string] = - ## Lists all the subdirectories (non-recursively) in the directory `dir`. - builtin -proc listFiles*(dir: string): seq[string] = - ## Lists all the files (non-recursively) in the directory `dir`. - builtin - +proc listDirsImpl(dir: string): seq[string] {. + tags: [ReadIOEffect], raises: [OSError].} = builtin +proc listFilesImpl(dir: string): seq[string] {. + tags: [ReadIOEffect], raises: [OSError].} = builtin proc removeDir(dir: string) {. tags: [ReadIOEffect, WriteIOEffect], raises: [OSError].} = builtin proc removeFile(dir: string) {. @@ -47,6 +44,7 @@ proc copyDir(src, dest: string) {. tags: [ReadIOEffect, WriteIOEffect], raises: [OSError].} = builtin proc createDir(dir: string) {.tags: [WriteIOEffect], raises: [OSError].} = builtin + proc getError: string = builtin proc setCurrentDir(dir: string) = builtin proc getCurrentDir*(): string = @@ -196,6 +194,16 @@ template log(msg: string, body: untyped) = if mode != ScriptMode.WhatIf: 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].} = ## Removes the directory `dir`. log "rmDir: " & dir: |