Learn R Programming

checkmate (version 1.0)

checkFile: Check existence and access rights of files

Description

Check existence and access rights of files

Usage

checkFile(x, access = "")

assertFile(x, access = "", .var.name)

testFile(x, access = "")

Arguments

x
[ANY] Object to check.
.var.name
[character(1)] Name for x. Defaults to a heuristic to determine the name using deparse and substitute.
access
[character(1)] Single string containing possible characters r, w and x to force a check for read, write or execute access rights, respectively.

Value

  • Depending on the function prefix: If the check is successful, all functions return TRUE. If the check is not successful, assertFile throws an error message, testFile returns FALSE and checkFile returns a string with the error message.

See Also

Other filesystem: assertAccess, checkAccess, testAccess; assertDirectory, checkDirectory, testDirectory; assertPathForOutput, checkPathForOutput, testPathForOutput

Examples

Run this code
# Check if R's COPYING file is readable
 testFile(file.path(R.home(), "COPYING"), access = "r")

 # Check if R's COPYING file is readable and writable
 testFile(file.path(R.home(), "COPYING"), access = "rw")

Run the code above in your browser using DataLab