summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisplib.c2
-rw-r--r--share/txr/stdlib/copy-file.tl7
-rw-r--r--txr.131
3 files changed, 39 insertions, 1 deletions
diff --git a/lisplib.c b/lisplib.c
index d97ad63d..af0029fb 100644
--- a/lisplib.c
+++ b/lisplib.c
@@ -815,7 +815,7 @@ static val copy_file_set_entries(val dlt, val fun)
val name[] = {
lit("copy-path-opts"), lit("copy-file"), lit("copy-files"),
lit("copy-path-rec"), lit("remove-path-rec"),
- lit("chown-rec"), lit("chmod-rec"),
+ lit("chown-rec"), lit("chmod-rec"), lit("touch"),
nil
};
set_dlt_entries(dlt, name, fun);
diff --git a/share/txr/stdlib/copy-file.tl b/share/txr/stdlib/copy-file.tl
index 52125fd4..5c67a254 100644
--- a/share/txr/stdlib/copy-file.tl
+++ b/share/txr/stdlib/copy-file.tl
@@ -212,5 +212,12 @@
(retry `retry chown @path` (exc . args)))))
(logior ftw-phys)))
+(defun touch (path : ref-path)
+ (with-stream (s (or (ignerr (open-file path "mn")) (open-file path "n")))
+ (if ref-path
+ (let ((rst (stat ref-path)))
+ (utimes s 0 nil rst.mtime rst.mtime-nsec))
+ (utimes s 0 nil 0 t))))
+
(eval-only
(merge-delete-package 'sys))
diff --git a/txr.1 b/txr.1
index 102a6a74..c02d7fb3 100644
--- a/txr.1
+++ b/txr.1
@@ -59197,6 +59197,37 @@ and
allowing the caller to retry individual failed operations or skip the objects
on which operations have failed.
+.coNP Function @ touch
+.synb
+.mets (touch < path <> [ ref-path ])
+.syne
+.desc
+The
+.code touch
+function updates the modification timestamp of the filesystem object
+named by
+.metn path .
+If the object doesn't exist, it is created as a regular file.
+
+If
+.meta ref-path
+is specified, then the modification timestamp of the object denoted by
+.meta path
+is updated to be equivalent to the modification timestamp of
+the object denoted by
+.metn ref-path .
+Otherwise
+.meta ref-path
+being absent, the modification timestamp of
+.meta path
+is set to the current time.
+
+If
+.meta path
+is a symbolic link, it is dereferenced;
+.code touch
+operates on the target of the link.
+
.SS* Unix Filesystem Object Existence, Type and Access Tests
Functions in this category perform various tests on the attributes of