1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Do not modify this file since it was automatically generated from:
%
% touchFile.R
%
% by the Rdoc compiler part of the R.oo package.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\name{touchFile}
\alias{touchFile.default}
\alias{touchFile}
\title{Updates the timestamp of a file}
\description{
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.
}
\usage{
\method{touchFile}{default}(pathname, ...)
}
\arguments{
\item{pathname}{A \code{\link[base]{character}} \code{\link[base]{vector}} specifying files to be updated.}
\item{...}{Not used.}
}
\value{
Returns (invisibly) a \code{\link[base]{vector}} of the old timestamps.
}
\examples{
# 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))
}
\author{Henrik Bengtsson}
\seealso{
Internally, \code{\link[base]{Sys.setFileTime}}() (iff available) and
\code{\link[base]{file.info}}() are utilized.
}
\references{
[1] R-devel mailing list thread
\emph{Unix-like touch to update modification timestamp of file?},
started on 2008-02-26.
\url{https://stat.ethz.ch/pipermail/r-devel/2008-February/048542.html}\cr
}
\keyword{programming}
\keyword{IO}
\keyword{file}
|