R/utils_files.R

Defines functions make_path

Documented in make_path

# file_ops.R
# ::rtemis::
# 2025 EDG rtemis.org

#' Expand, normalize, concatenate, clean path
#'
#' @param ... Character: Parts of path to concatenate.
#' @param expand_path Logical: If TRUE, expand concatenated path using [path.expand].
#'
#' @return Character: Path.
#'
#' @author EDG
#' @export
make_path <- function(..., expand_path = TRUE) {
  path <- list(...)
  # Remove final "/"
  path <- lapply(path, \(x) gsub("\\/$", "", x))
  # Concat
  path <- do.call(file.path, path)
  # Expand
  if (expand_path) {
    path <- path.expand(path)
  }
  path
} # rtemis::make_path
egenn/rtemis documentation built on June 14, 2025, 11:54 p.m.