Functions to test for file types
Usage
is_file(path, follow = TRUE)
is_dir(path, follow = TRUE)
is_link(path)
is_file_empty(path, follow = TRUE)
Value
A named logical vector, where the names give the paths. If the given
object does not exist, NA
is returned.
See also
file_exists()
, dir_exists()
and link_exists()
if you want
to ensure that the path also exists.
Examples
dir_create("d")
file_create("d/file.txt")
dir_create("d/dir")
link_create(path(path_abs("d"), "file.txt"), "d/link")
paths <- dir_ls("d")
is_file(paths)
#> d/dir d/file.txt d/link
#> FALSE TRUE TRUE
is_dir(paths)
#> d/dir d/file.txt d/link
#> TRUE FALSE FALSE
is_link(paths)
#> d/dir d/file.txt d/link
#> FALSE FALSE TRUE
# Cleanup
dir_delete("d")