Learn R Programming

assertive.files (version 0.0-1)

assert_all_are_empty_files: Is a file too big or small?

Description

Checks to see if a file is within a given size range.

Usage

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

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

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

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

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

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

is_file_size_in_range(x, lower = 0, upper = Inf, lower_is_strict = FALSE, upper_is_strict = FALSE, .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.
lower
Smallest file size allowed, in bytes.
upper
Largest file size allowed, in bytes.
lower_is_strict
If TRUE, the lower bound is open (strict) otherwise it is closed.
upper_is_strict
If TRUE, the upper bound is open (strict) otherwise it is closed.

Value

  • is_empty_file wraps file.info, retuning TRUE when the input is a file that exists with size zero. assert_*_are_empty_files return nothing but throws an error if is_empty_file returns FALSE.

See Also

file.info.

Examples

Run this code
tf <- tempfile()
file.create(tf)
is_empty_file(tf)
cat("some stuff", file = tf)
is_non_empty_file(tf)
is_file_size_in_range(tf, lower = 100)
unlink(tf)

Run the code above in your browser using DataLab