Updates the timestamp of a file. Currently, it is only possible to change the timestamp specifying when the file was last modified, and time can only be set to the current time.
Returns (invisibly) a
vector of the old timestamps.
 R-devel mailing list thread
Unix-like touch to update modification timestamp of file?,
started on 2008-02-26.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# 1. Create a file pathname <- tempfile() cat(file=pathname, "Hello world!") md5a <- digest::digest(pathname, file=TRUE) # 2. Current time stamp ta <- file.info(pathname)$mtime print(ta) # 3. Update time stamp Sys.sleep(1.2) touchFile(pathname) tb <- file.info(pathname)$mtime print(tb) # 4. Verify that the timestamp got updated stopifnot(tb > ta) # 5. Verify that the contents did not change md5b <- digest::digest(pathname, file=TRUE) stopifnot(identical(md5a, md5b))
Loading required package: R.oo Loading required package: R.methodsS3 R.methodsS3 v1.7.1 (2016-02-15) successfully loaded. See ?R.methodsS3 for help. R.oo v1.22.0 (2018-04-21) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following objects are masked from 'package:methods': getClasses, getMethods The following objects are masked from 'package:base': attach, detach, gc, load, save R.utils v2.8.0 successfully loaded. See ?R.utils for help. Attaching package: 'R.utils' The following object is masked from 'package:utils': timestamp The following objects are masked from 'package:base': cat, commandArgs, getOption, inherits, isOpen, parse, warnings  "2019-03-25 20:07:04 UTC"  "2019-03-25 20:07:05 UTC"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.