Skip to contents

Assert That File Exists

Usage

check_file(x, exists = TRUE, msg = "error")

Arguments

x

File name.

exists

Logical. If TRUE (default), it will check if the files exist. Otherwise it will check if there is no file of given (x) name.

msg

Character. Should test print one of warning or error.

Value

If file exists and exists = FALSE it will throw:

  • error when msg = "error"

  • warning when msg = "warning.

Examples

if (FALSE) { # \dontrun{
check_file("new_file.R", exists = FALSE)
check_file("xyz/new_f.R", exists = TRUE)
} # }