is_empty_file: Is a file too big or small?

Description Usage Arguments Value See Also Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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"))

assert_all_file_sizes_are_in_range(x, lower = 0, upper = Inf,
  lower_is_strict = FALSE, upper_is_strict = FALSE, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_any_file_sizes_are_in_range(x, lower = 0, upper = Inf,
  lower_is_strict = FALSE, upper_is_strict = FALSE,
  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".

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.

na_ignore

A logical value. If FALSE, NA values cause an error; otherwise they do not. Like na.rm in many stats package functions, except that the position of the failing values does not change.

.xname

Not intended to be used directly.

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

1
2
3
4
5
6
7
tf <- tempfile()
file.create(tf)
is_empty_file(tf)
cat("some stuff", file = tf)
is_non_empty_file(tf)
assertive.base::dont_stop(assert_all_file_sizes_are_in_range(tf, lower = 100))
unlink(tf)  

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