mostRecentTimestamp: Identify the timestamp of the most recently modified file in...

Description Usage Arguments Value Examples

View source: R/fileCache.R

Description

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.

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(lubridate)

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')
}

weinbergerlab/ExcessILI documentation built on May 30, 2021, 10:57 a.m.