1% File src/library/utils/man/filetest.Rd 2% Part of the R package, https://www.R-project.org 3% Copyright 1995-2009 R Core Team 4% Distributed under GPL 2 or later 5 6\name{file_test} 7\alias{file_test} 8\title{ 9 Shell-style Tests on Files 10} 11\description{ 12 Utility for shell-style file tests. 13} 14\usage{ 15file_test(op, x, y) 16} 17\arguments{ 18 \item{op}{a character string specifying the test to be performed. 19 Unary tests (only \code{x} is used) are \code{"-f"} (existence and 20 not being a directory), \code{"-d"} (existence and directory) and 21 \code{"-x"} (executable as a file or searchable as a directory). 22 Binary tests are \code{"-nt"} (strictly newer than, using the modification 23 dates) and \code{"-ot"} (strictly older than): in both cases the 24 test is false unless both files exist.} 25 \item{x, y}{character vectors giving file paths.} 26} 27\details{ 28 \sQuote{Existence} here means being on the file system and accessible 29 by the \code{stat} system call (or a 64-bit extension) -- on a 30 Unix-alike this requires execute permission on all of the directories in 31 the path that leads to the file, but no permissions on the file 32 itself. 33 34 For the meaning of \code{"-x"} on Windows see \code{\link{file.access}}. 35} 36\seealso{ 37 \code{\link{file.exists}} which only tests for existence 38 (\code{test -e} on some systems) but not for not being a directory. 39 40 \code{\link{file.path}}, \code{\link{file.info}} 41} 42\examples{ 43dir <- file.path(R.home(), "library", "stats") 44file_test("-d", dir) 45file_test("-nt", file.path(dir, "R"), file.path(dir, "demo")) 46} 47\keyword{file} 48