check_path_type: Check the Type of an Input Path

View source: R/check_path_type.R

check_path_typeR Documentation

Check the Type of an Input Path

Description

Checks whether the input path points to a folder or to a file. Before the check, the path is cleaned automatically: backslashes are converted to forward slashes, invisible characters that are often copied along with paths from 'Windows' dialogs (U+202A) are removed, and a redundant trailing "/" is dropped.

Usage

check_path_type(path)

Arguments

path

Character string; the path to check. Anything that is not a single, non-missing, non-empty character string is treated as invalid.

Details

The function never stops: it always returns one of the four type labels below, so callers can branch directly on the result. The cleaned path is used for the existence checks, which makes the function robust against paths copied out of the 'Windows' Explorer address bar. It is used internally by the reading functions of the package to support both folder input (batch mode) and single-file input.

Value

A character string, one of

"folder"

the path exists and is a folder

"csv file"

the path exists, is a file and has the extension csv

"other file"

the path exists and is a file with another extension

"invalid path"

the path does not exist or is not a valid path string

See Also

lc50_read

Examples

check_path_type(tempdir())
check_path_type(system.file("extdata", "lc50_example.csv", package = "insectecol"))

insectecol documentation built on Oct. 5, 2026, 5:08 p.m.