summaryrefslogtreecommitdiffstats
path: root/share/txr/stdlib/path-test.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-10-29 22:32:14 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-10-29 22:32:14 -0700
commit5f5d7f2e69b9f80dcbbe3f6e0626e4664db70364 (patch)
tree11ac8b173852faa53fc0e3bbf2194ba058f0b0cc /share/txr/stdlib/path-test.tl
parent6896d02e5bdb2deb0f0b3d3becfe55dd9981a78b (diff)
downloadtxr-5f5d7f2e69b9f80dcbbe3f6e0626e4664db70364.tar.gz
txr-5f5d7f2e69b9f80dcbbe3f6e0626e4664db70364.tar.bz2
txr-5f5d7f2e69b9f80dcbbe3f6e0626e4664db70364.zip
stat: support high resolution time stamps.
* configure (have_sys_stat): New variable. Set to y when our test detects <sys/stat.h>. New test added for the presence of high resolution time stamps in struct stat. If we have these, we #define HAVE_STAT_NSEC 1 in config.h. * share/txr/stdlib/path-test.tl (path-newer): Compare nanosecond parts of the modification time if the seconds are equal, improving the resolution of the test. * sysif.c (atime_nsec_s, mtime_nsec_s, ctime_nsec_s): New symbol variables. (stat_to_struct): If nanosecond resolution is available, set the new nanosecond slots from the three tv_nsec fields in struct stat. Otherwise, set the new slots to zero. (sysif_init): Initialize the new symbol variables. Add the three new slots to the stat struct. * sysif.c (atime_nsec_s, mtime_nsec_s, ctime_nsec_s): Declared. * txr.1: Documented new atime-nsec, mtime-nsec and ctime-nsec slots of stat structure. Added note to path-newer mentioning high resolution support.
Diffstat (limited to 'share/txr/stdlib/path-test.tl')
-rw-r--r--share/txr/stdlib/path-test.tl8
1 files changed, 7 insertions, 1 deletions
diff --git a/share/txr/stdlib/path-test.tl b/share/txr/stdlib/path-test.tl
index 59b24b13..4e26f1f8 100644
--- a/share/txr/stdlib/path-test.tl
+++ b/share/txr/stdlib/path-test.tl
@@ -153,7 +153,13 @@
(defun path-newer (path-0 path-1)
(sys:path-examine (s0 stat path-0)
(sys:path-examine (s1 stat path-1)
- (and s0 (or (not s1) (> s0.mtime s1.mtime))))))
+ (if s0
+ (or (null s1)
+ (let ((mt0 s0.mtime)
+ (mt1 s1.mtime))
+ (or (> mt0 mt1)
+ (and (= mt0 mt1)
+ (> s0.mtime-nsec s1.mtime-nsec)))))))))
(defun path-older (path-0 path-1)
(path-newer path-1 path-0))