Lisp HUG Maillist Archive

touch-file

Is there a good way to change the modification date of a file?  I
found sys:set-file-dates, but it doesn't appear to be documented.  

Also, what's a good way to to create an empty file?  I can just use
with-open-file, but that doesn't seem like exactly the right thing.

My goal is to write touch-file:

    (defun touch-file (file-name &key time)
      (if (file-exists-p file-name)
          (let ((now (or time (get-universal-time))))
            (sys:set-file-dates file-name :modification now :access now))
          (with-open-file (out file-name :direction :output)
            (declare (ignore out)))))

Thanks!

Regards,
Chris Dean


Updated at: 2020-12-10 08:49 UTC