-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathutils.R
More file actions
32 lines (23 loc) · 1.02 KB
/
Copy pathutils.R
File metadata and controls
32 lines (23 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# like system.file(), but injects the architecture-specific subdirectory
# used on Windows when set; e.g. systemFile("lib") resolves 'lib/x64'
systemFile <- 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
}