Returns the timestamp of the most recently modified file. If no such file exists, or if the directory basepath/fname doesn't exist, returns NA.

mostRecentTimestamp(fname, basepath = ".")

Arguments

fname

The name of the directory in basepath where various revisions of the file are stored. I.e., file.txt should be a directory, with revisions of the true file.txt stored inside of it.

basepath

A string. The path which stores the fname directory. Default '.'

Value

A POSIXct object specifying the mtime of the most recently modified file in basepath/fname

Examples

library(lubridate)
#> #> Attaching package: 'lubridate'
#> The following object is masked from 'package:base': #> #> date
saveRDS(mtcars, 'cars') saveRDS(mtcars, 'cars') # Some time elapses... # Decide if the latest version of 'mtcars' is "too old" if (mostRecentTimestamp('mtcars') %--% now() > hours(24)) { # Store a "new" version saveRDS(mtcars, 'cars') } else { cached_mtcars <- retrieveRDS('mtcars') }