file_test

0th

Percentile

Shell-style Tests on Files

Utility for shell-style file tests.

Keywords
file
Usage
file_test(op, x, y)
Arguments
op
a character string specifying the test to be performed. Unary tests (only x is used) are "-f" (existence and not being a directory), "-d" (existence and directory) and "-x" (executable as a file or searchable as a directory). Binary tests are "-nt" (strictly newer than, using the modification dates) and "-ot" (strictly older than): in both cases the test is false unless both files exist.
x, y
character vectors giving file paths.
Details

‘Existence’ here means being on the file system and accessible by the stat system call (or a 64-bit extension) -- on a Unix-alike this requires execute permission on all of the directories in the path that leads to the file, but no permissions on the file itself.

For the meaning of "-x" on Windows see file.access.

See Also

file.exists which only tests for existence (test -e on some systems) but not for not being a directory.

file.path, file.info

Aliases
  • file_test
Examples
library(utils) dir <- file.path(R.home(), "library", "stats") file_test("-d", dir) file_test("-nt", file.path(dir, "R"), file.path(dir, "demo"))
Documentation reproduced from package utils, version 3.1.2, License: Part of R 3.1.2

Community examples

Looks like there are no examples yet.