Convert file paths to their Unix or Windows representations
path_to_unix(path = NULL, ask = FALSE, normalize = TRUE)
path_to_windows(path = NULL, ask = FALSE, normalize = TRUE)file paths. Defaults to the path of the source editor context.
logical indicating whether to interactively ask for input.
This is particularly helpful for file paths including single backslashes
(Windows paths).
logical indicating whether to normalize the file
paths. Ignored on platforms other than the desired OS. When TRUE,
files that do not exist result in NA.
character vector with length of path containing the
converted paths.
Paths are split by commas. Paths that do not exist result in
NA if normalize is TRUE.
When converting to Unix representation, paths in Windows 'C:/' result in
NA since there is no Unix equivalent.
When converting to Windows representation, paths not in '~', '/cognigen',
'/doc', '/home', '/miguel', or '/misc' result in NA since there is
no Windows equivalent.
Also see the Toggle File Path Selection RStudio Addin.
if (FALSE) { # \dontrun{
# Ask for input
path_to_unix(ask = TRUE)
# Get the Windows representation for the active source document
path_to_windows()
# Get the theoretical Unix representation of Windows paths without checking for their existence
path_to_unix(c("M:/client/drug", "M:\\client2\\drug"), normalize = FALSE)
# Get the Windows representation of Unix paths, checking for their existence (if using Windows)
path_to_windows(c("/doc/client/drug", "/doc/client2/drug"), normalize = TRUE)
} # }