fs
fs copied to clipboard
Inconsistent treatment of non-character path inputs
Some functions (e.g. path_tidy) call enc2utf8(as.character(path)), but others do not coerce to character first (e.g. path_expand just calls enc2utf8(path)). This leads to inconsistent treatment of non-character path inputs between different functions:
> fs::path_tidy(NA)
NA
> fs::path_expand(NA)
Error in enc2utf8(path) : argument is not a character vector
and also logically-inconsistent behaviour in some cases:
> fs::file_exists(NA_character_)
<NA>
FALSE
but
> fs::file_exists(NA)
Error in enc2utf8(path) : argument is not a character vector
If this isn't intentional, would it be unreasonable to apply an as.character coercion to all calls to enc2utf8 to avoid these errors?
I think it would make sense to try to convert to characters, would you like to submit a PR?
OK, will do.