fs
fs copied to clipboard
path_tidy breaks paths with backslashes in them
I'm on Linux, and I'm dealing with some paths that, for reasons unknown to me, contain backslashes in the file names. It seems that the fs package abjectly refuses to admit the existence of backslashes:
library(fs)
library(assertthat)
myfile <- tempfile("path with a back\\slash")
system(paste("touch", shQuote(myfile)))
assert_that(file.exists(myfile))
#> [1] TRUE
## Fails
assert_that(file_exists(myfile))
#> Error: file_exists(path = myfile) is not TRUE
myfile_tidy <- path_tidy(myfile)
print(myfile_tidy)
#> /var/folders/dt/6dg7l6491fjdpb17tfgld9rc0000gn/T/RtmpHj4ctg/path with a back/slash62c12c0f5718
regex_matching_one_backslash <- "\\\\"
assert_that(grepl(regex_matching_one_backslash, myfile))
#> [1] TRUE
## Fails
assert_that(grepl(regex_matching_one_backslash, myfile_tidy))
#> Error: grepl(pattern = regex_matching_one_backslash, x = myfile_tidy) is not TRUE
Created on 2022-07-21 by the reprex package (v2.0.1)
I'm guessing the package is trying to enforce the same path separator for UNIX and Windows systems, but does this mean that paths with backslashes in them are simply not supported at all?