diff options
Diffstat (limited to 'lib/pure/os.nim')
-rw-r--r-- | lib/pure/os.nim | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 5efbde268..2601f9d47 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1682,7 +1682,7 @@ proc setFilePermissions*(filename: string, permissions: set[FilePermission]) {. proc copyFile*(source, dest: string) {.rtl, extern: "nos$1", tags: [ReadIOEffect, WriteIOEffect], noWeirdTarget.} = - ## Copies a file from `source` to `dest`. + ## Copies a file from `source` to `dest`, where `dest.parentDir` must exist. ## ## If this fails, `OSError` is raised. ## @@ -1738,6 +1738,12 @@ proc copyFile*(source, dest: string) {.rtl, extern: "nos$1", flushFile(d) close(d) +proc copyFileToDir*(source, dir: string) {.noWeirdTarget, since: (1,3,7).} = + ## Copies a file `source` into directory `dir`, which must exist. + if dir.len == 0: # treating "" as "." is error prone + raise newException(ValueError, "dest is empty") + copyFile(source, dir / source.lastPathPart) + when not declared(ENOENT) and not defined(Windows): when NoFakeVars: when not defined(haiku): |