summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorCharles Blake <cb@cblake.net>2017-02-07 09:39:41 -0500
committerCharles Blake <cb@cblake.net>2017-02-07 09:39:41 -0500
commit3680cbaf25a1b25fa14c82be249ef0eca235f0de (patch)
treeadd189302e2b7a6aa3a83a9e5e23f4a022542e48 /lib
parent53dfb21d6c227ee940fd20fdce321f19f8c656b9 (diff)
downloadNim-3680cbaf25a1b25fa14c82be249ef0eca235f0de.tar.gz
Use old approach for Mac OSX which, as of 2016, does not yet support POSIX
high-resolution file times.
Diffstat (limited to 'lib')
-rw-r--r--lib/posix/posix.nim30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim
index 9338fcd99..a08da2dfa 100644
--- a/lib/posix/posix.nim
+++ b/lib/posix/posix.nim
@@ -275,9 +275,14 @@ type
                            ## For a typed memory object, the length in bytes.
                            ## For other file types, the use of this field is
                            ## unspecified.
-    st_atim*: Timespec     ## Time of last access.
-    st_mtim*: Timespec     ## Time of last data modification.
-    st_ctim*: Timespec     ## Time of last status change.
+    when defined(macosx):
+      st_atime*: Time      ## Time of last access.
+      st_mtime*: Time      ## Time of last data modification.
+      st_ctime*: Time      ## Time of last status change.
+    else:
+      st_atim*: Timespec   ## Time of last access.
+      st_mtim*: Timespec   ## Time of last data modification.
+      st_ctim*: Timespec   ## 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.
@@ -1610,15 +1615,16 @@ var
   MSG_OOB* {.importc, header: "<sys/socket.h>".}: cint
     ## Out-of-band data.
 
-proc st_atime*(s: Stat): Time {.inline.} =
-  ## Second-granularity time of last access
-  result = s.st_atim.tv_sec
-proc st_mtime*(s: Stat): Time {.inline.} =
-  ## Second-granularity time of last data modification.
-  result = s.st_mtim.tv_sec
-proc st_ctime*(s: Stat): Time {.inline.} =
-  ## Second-granularity time of last status change.
-  result = s.st_ctim.tv_sec
+when not defined(macosx):
+  proc st_atime*(s: Stat): Time {.inline.} =
+    ## Second-granularity time of last access
+    result = s.st_atim.tv_sec
+  proc st_mtime*(s: Stat): Time {.inline.} =
+    ## Second-granularity time of last data modification.
+    result = s.st_mtim.tv_sec
+  proc st_ctime*(s: Stat): Time {.inline.} =
+    ## Second-granularity time of last status change.
+    result = s.st_ctim.tv_sec
 
 proc WIFCONTINUED*(s:cint) : bool {.importc, header: "<sys/wait.h>".}
   ## True if child has been continued.