R/path.R

Defines functions path

path <- function(path, name) {
  flob_ext <- ext(name)
  flob_name <- file(name)

  if (ends_with_file_separator(path)) {
    return(p0(path, flob_name, ".", flob_ext))
  }

  path_ext <- tools::file_ext(path)

  if (identical(path_ext, "")) {
    return(p0(path, ".", flob_ext))
  }

  if (!identical(path_ext, flob_ext)) {
    err("Path extension must match '", flob_ext, "'.",
      class = "flobr_error"
    )
  }

  path
}
poissonconsulting/flobr documentation built on June 10, 2025, 3:02 a.m.