diff options
author | Araq <rumpf_a@web.de> | 2018-06-08 19:50:36 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-06-08 19:50:36 +0200 |
commit | 8e9551b1c7614029f12e7d62ba81f367d1aaf6bd (patch) | |
tree | 6aaa97a9734784ab5a65d1d2975100e4dd9872d1 /lib/posix | |
parent | 8ba7e7d807c37a0988abd69ef9824b4822fe04f3 (diff) | |
parent | f99acdb07584d2c4c5eb1f22d998d97bcd823357 (diff) | |
download | Nim-8e9551b1c7614029f12e7d62ba81f367d1aaf6bd.tar.gz |
fixex merge conflicts
Diffstat (limited to 'lib/posix')
-rw-r--r-- | lib/posix/posix.nim | 22 | ||||
-rw-r--r-- | lib/posix/posix_other.nim | 10 |
2 files changed, 25 insertions, 7 deletions
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index 3ff156bdf..db5f575af 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -82,6 +82,14 @@ const # Special types type Sighandler = proc (a: cint) {.noconv.} +const StatHasNanoseconds* = defined(linux) or defined(freebsd) 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 + ## without checking this flag, because this module defines fallback procs + ## when they are not available. + # Platform specific stuff when defined(linux) and defined(amd64): @@ -92,9 +100,9 @@ else: # There used to be this name in posix.nim a long time ago, not sure why! {.deprecated: [cSIG_HOLD: SIG_HOLD].} -when not defined(macosx) and not defined(android): +when StatHasNanoseconds: proc st_atime*(s: Stat): Time {.inline.} = - ## Second-granularity time of last access + ## 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. @@ -102,6 +110,16 @@ when not defined(macosx) and not defined(android): proc st_ctime*(s: Stat): Time {.inline.} = ## Second-granularity time of last status change. result = s.st_ctim.tv_sec +else: + proc st_atim*(s: Stat): TimeSpec {.inline.} = + ## Nanosecond-granularity time of last access. + result.tv_sec = s.st_atime + proc st_mtim*(s: Stat): TimeSpec {.inline.} = + ## Nanosecond-granularity time of last data modification. + result.tv_sec = s.st_mtime + proc st_ctim*(s: Stat): TimeSpec {.inline.} = + ## Nanosecond-granularity time of last data modification. + result.tv_sec = s.st_ctime when hasAioH: proc aio_cancel*(a1: cint, a2: ptr Taiocb): cint {.importc, header: "<aio.h>".} diff --git a/lib/posix/posix_other.nim b/lib/posix/posix_other.nim index 004a4205b..b7570bd15 100644 --- a/lib/posix/posix_other.nim +++ b/lib/posix/posix_other.nim @@ -215,14 +215,14 @@ type ## For a typed memory object, the length in bytes. ## For other file types, the use of this field is ## unspecified. - when defined(macosx) or defined(android): - st_atime*: Time ## Time of last access. - st_mtime*: Time ## Time of last data modification. - st_ctime*: Time ## Time of last status change. - else: + when 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. |