Learn R Programming

fs (version 1.0.0)

is_file: Functions to test for file types

Description

Functions to test for file types

Usage

is_file(path)

is_dir(path)

is_link(path)

Arguments

path

A character vector of one or more paths.

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

Run this code
# NOT RUN {
tmp <- dir_create(file_temp())

file_create(path(tmp, "file.txt"))
dir_create(path(tmp, "dir"))
link_create(path(tmp, "file.txt"), path(tmp, "link"))

paths <- dir_ls(tmp)
is_file(paths)
is_dir(paths)
is_link(paths)
# }

Run the code above in your browser using DataLab