Skip to content

Commit

Permalink
Use fs::is_dir() because fs::is_file() is buggy.
Browse files Browse the repository at this point in the history
  • Loading branch information
MLopez-Ibanez committed Jan 7, 2024
1 parent 2940788 commit 5e30228
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/path_rel2abs.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#' @export
path_rel2abs <- function (path, cwd = getwd())
{
# FIXME: split this function into two, one for executable files than handles
# finding executables in the PATH with Sys.which() and another for everything
# else that doesn't try to be that smart.

# We need to do this even with the path returned by `getwd()`.
cwd <- fs::path_norm(fs::path_expand(cwd))

Expand All @@ -26,7 +30,7 @@ path_rel2abs <- function (path, cwd = getwd())
sys_path <- suppressWarnings(Sys.which(path))
if (nzchar(sys_path)
&& fs::file_access(sys_path, "execute")
&& fs::is_file(sys_path)) {
&& !fs::is_dir(sys_path)) {
path <- as.vector(sys_path)
}
}
Expand Down

0 comments on commit 5e30228

Please sign in to comment.