Skip to contents

Construct the path to a file from components in a platform-independent way. This version is a wrapper of the base file.path function which also reverses '/' direction and can attempt to add double slashes if needed.

Usage

file.path(
  ...,
  path_separator = getOption("path_separator"),
  leading_string = getOption("leading_string"),
  change_path_chars = NULL,
  change_leading_chars = c("/", "\\", "\\\\")
)

Arguments

...

character vectors. Long vectors are not supported.

path_separator

the path separator to use (assumed to be ASCII).

leading_string

what is the leading character(s) (e.g., '/' or '\\'). A string can be provided, or by default if the "leading_string" global variable is set it takes that variable, otherwise this is guessed at based on operating system and/or existence of a file at the file path

change_path_chars

which characters should be changes to the path_separator value (default NULL = "none"). If you want to change all slashes in the file path to the correct direction set change_chars = c("/","\"))

change_leading_chars

which characters should be changes to the leading_string value (default = c("/","\","\\")). This will preserve local file paths.

Value

A file path with slashes going the correct direction.