R/utils-path.R

Defines functions .path_data .path_x .generate_path

#' @noRd
#' @export
.generate_path <- function(path = NULL, dir, file, ext) {
  if(!is.null(path)) {
    return(path)
  }
  file.path(dir, sprintf('%s.%s', file, ext))
}

#' @noRd
#' @export
.path_x <- function(dir, file = tempfile(), ext = NULL) {
  if(!is.null(ext)) {
    ext <- sprintf('.%s', ext)
  } else {
    ext <- ''
  }
  file.path(dir, sprintf('%s%s', file, ext))
}

#' @noRd
#' @export
.path_data <- function(dir = get_dir_data(), ...) {
  .path_x(dir = dir, ...)
}
tonyelhabr/xengagement documentation built on June 22, 2022, 5 a.m.