correctWinPath: Correct mixed slash and backslash in file path

View source: R/correctWinPath.R

correctWinPathR Documentation

Correct mixed slash and backslash in file path

Description

This function corrects paths character strings for mixed slash and backslash in file path. In Windows the function tempdir() will use double backslashes as separator while file.path() uses regular slashes. So when combining these two one might encounter a mix of slashes and double backslashes which may cause trouble, unless this is streightened out to a single separator used. When pointig to given files inside html-files, paths need to have a prefix, this can be added using the argument asHtml.

Usage

correctWinPath(
  x,
  asHtml = FALSE,
  anyPlatf = FALSE,
  silent = TRUE,
  callFrom = NULL
)

Arguments

x

(character) input path to test and correct

asHtml

(logical) option for use in html : add prefix "file:/"

anyPlatf

(logical) if TRUE, checking will only be performed in Windows environement

silent

(logical) suppress messages

callFrom

(character) allows easier tracking of message(s) produced

Value

character vector with corrected path

See Also

tempfile, file.path

Examples

path1 <- 'D:\\temp\\Rtmp6X8/working_dir\\RtmpKC/example.txt'
(path1b <- correctWinPath(path1, anyPlatf=TRUE)) 
(path1h <- correctWinPath(path1, anyPlatf=TRUE, asHtml=TRUE)) 

wrMisc documentation built on Jan. 7, 2023, 1:27 a.m.