summary refs log tree commit diff stats
path: root/lib/posix
diff options
context:
space:
mode:
authorRoman Inflianskas <rominf@users.noreply.github.com>2021-02-04 09:57:41 -0800
committerGitHub <noreply@github.com>2021-02-04 18:57:41 +0100
commite9b360c5dfac2331a57b1cc3310fc85fe65fe7af (patch)
treef9069b880b52ea6f81a15b2128e34c6227db9e0c /lib/posix
parentbb85bc7ebc68e240f955015cd80f76ac424c16b5 (diff)
downloadNim-e9b360c5dfac2331a57b1cc3310fc85fe65fe7af.tar.gz
stdlib/os: handle symlinks in copy/move functions (#16709)
* stdlib/os: handle symlinks in copy/move functions

- Added optional `options` argument to `copyFile`, `copyFileToDir`, and
  `copyFileWithPermissions`. By default, symlinks are followed (copy files
  symlinks point to).
- `copyDir` and `copyDirWithPermissions` copy symlinks as symlinks (instead of
  skipping them as it was before).
- `moveFile` and `moveDir` move symlinks as symlinks (instead of skipping them
  sometimes as it was before).
- Added optional `followSymlinks` argument to `setFilePermissions`.

See also: https://github.com/nim-lang/RFCs/issues/319

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Address comments in #16709

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Address comments in #16709 (second iteration)

Skip symlinks on Windows.

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
Diffstat (limited to 'lib/posix')
-rw-r--r--lib/posix/posix.nim2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim
index c7a324cde..e8ad786e9 100644
--- a/lib/posix/posix.nim
+++ b/lib/posix/posix.nim
@@ -586,6 +586,8 @@ proc fstatvfs*(a1: cint, a2: var Statvfs): cint {.
   importc, header: "<sys/statvfs.h>".}
 
 proc chmod*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>", sideEffect.}
+when defined(osx) or defined(freebsd):
+  proc lchmod*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>", sideEffect.}
 proc fchmod*(a1: cint, a2: Mode): cint {.importc, header: "<sys/stat.h>", sideEffect.}
 proc fstat*(a1: cint, a2: var Stat): cint {.importc, header: "<sys/stat.h>", sideEffect.}
 proc lstat*(a1: cstring, a2: var Stat): cint {.importc, header: "<sys/stat.h>", sideEffect.}