R/utils.R

Defines functions asBuildPath archSystemFile verboseMessage

# opt-in diagnostics, primarily useful when debugging issues with
# TBB library resolution and loading during package load; uses the
# same VERBOSE environment variable as the TBB build in install.libs.R
verboseMessage <- function(fmt, ...) {
   verbose <- Sys.getenv("VERBOSE", unset = "0")
   if (!identical(verbose, "0"))
      message(sprintf(fmt, ...))
}

# like system.file(), but injects the architecture-specific subdirectory
# used on Windows when set; e.g. archSystemFile("lib") resolves 'lib/x64'
archSystemFile <- function(dir, name = NULL) {
   arch <- .Platform$r_arch
   parts <- c(dir, if (nzchar(arch)) arch, name)
   system.file(paste(parts, collapse = "/"), package = "RcppParallel")
}

# generate paths consumable by the compilers and linkers
# in particular, on Windows and Solaris, this means the path _cannot_ be quoted !!
asBuildPath <- function(path) {

   # normalize paths using forward slashes
   path <- normalizePath(path, winslash = "/", mustWork = FALSE)

   # prefer short path names if the path has spaces
   if (is_windows() && grepl(" ", path, fixed = TRUE))
      path <- utils::shortPathName(path)

   # if we still have spaces, and we're not Windows or Solaris, try quoting
   if (grepl(" ", path, fixed = TRUE) && !is_solaris())
      path <- shQuote(path)

   # ensure we use forward slashes, even on Windows
   path <- chartr("\\", "/", path)

   # return path
   path

}

Try the RcppParallel package in your browser

Any scripts or data that you put into this service are public.

RcppParallel documentation built on July 27, 2026, 5:08 p.m.