Skip to content

Commit

Permalink
osx: support nanosecond resolution for file stat (eg getLastModificat…
Browse files Browse the repository at this point in the history
…ionTime) (#12794)
  • Loading branch information
timotheecour authored and Araq committed Dec 4, 2019
1 parent 01c7409 commit 3383985
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/posix/posix.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion lib/posix/posix_macos_amd64.nim
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,19 @@ 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.
else:
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.
Expand Down

0 comments on commit 3383985

Please sign in to comment.