is_existing_file: Does the file exist?

Description Usage Arguments Value Note See Also Examples

Description

Checks to see if the input files exist.

Usage

1
2
3
4
5
6
7
assert_all_are_existing_files(x, severity = getOption("assertive.severity",
  "stop"))

assert_any_are_existing_files(x, severity = getOption("assertive.severity",
  "stop"))

is_existing_file(x, .xname = get_name_in_parent(x))

Arguments

x

Input to check.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

.xname

Not intended to be used directly.

Value

is_existing_file wraps file.exists, showing the names of the inputs in the answer. assert_*_are_existing_files return nothing but throws an error if is_existing_file returns FALSE.

Note

Trailing slashes are removed from paths to avoid a lot of false negatives by the underlying function file.exists.

See Also

file.exists.

Examples

1
2
3
4
5
assert_all_are_existing_files(dir())
# These examples should fail.
assertive.base::dont_stop(
  assert_all_are_existing_files("not an existing file (probably)")
)

Example output

$`assert_all_are_existing_files("not an existing file (probably)")`
<assertionError: is_existing_file : Some or all of the files specified by "not an existing file (probably)" do not exist.
There was 1 failure:
  Position                           Value       Cause
1        1 not an existing file (probably) nonexistent>

assertive.files documentation built on May 2, 2019, 1:29 p.m.