diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2019-12-04 01:12:55 -0600 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-12-04 08:12:55 +0100 |
commit | 3383985c44d6f9b1cd12160295134345e9c21830 (patch) | |
tree | d55f645b32b1cf7bd4a77ba5e9c3a647836e185d /lib/posix | |
parent | 01c74099245e2c1a3efe7af6c55460c820c896ea (diff) | |
download | Nim-3383985c44d6f9b1cd12160295134345e9c21830.tar.gz |
osx: support nanosecond resolution for file stat (eg getLastModificationTime) (#12794)
Diffstat (limited to 'lib/posix')
-rw-r--r-- | lib/posix/posix.nim | 2 | ||||
-rw-r--r-- | lib/posix/posix_macos_amd64.nim | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index ebd5eb54f..8856f2d65 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -86,7 +86,7 @@ const type Sighandler = proc (a: cint) {.noconv.} const StatHasNanoseconds* = defined(linux) or defined(freebsd) or - defined(openbsd) or defined(dragonfly) ## \ + defined(osx) or defined(openbsd) or defined(dragonfly) ## \ ## Boolean flag that indicates if the system supports nanosecond time ## resolution in the fields of ``Stat``. Note that the nanosecond based fields ## (``Stat.st_atim``, ``Stat.st_mtim`` and ``Stat.st_ctim``) can be accessed diff --git a/lib/posix/posix_macos_amd64.nim b/lib/posix/posix_macos_amd64.nim index 0687267f0..8a20d127f 100644 --- a/lib/posix/posix_macos_amd64.nim +++ b/lib/posix/posix_macos_amd64.nim @@ -217,7 +217,11 @@ type ## For a typed memory object, the length in bytes. ## For other file types, the use of this field is ## unspecified. - when StatHasNanoseconds: + when defined(osx): + st_atim* {.importc:"st_atimespec".}: Timespec ## Time of last access. + st_mtim* {.importc:"st_mtimespec".}: Timespec ## Time of last data modification. + st_ctim* {.importc:"st_ctimespec".}: Timespec ## Time of last status change. + elif StatHasNanoseconds: st_atim*: Timespec ## Time of last access. st_mtim*: Timespec ## Time of last data modification. st_ctim*: Timespec ## Time of last status change. @@ -225,6 +229,7 @@ type st_atime*: Time ## Time of last access. st_mtime*: Time ## Time of last data modification. st_ctime*: Time ## Time of last status change. + st_blksize*: Blksize ## A file system-specific preferred I/O block size ## for this object. In some file system types, this ## may vary from file to file. |