To create a path to a file in a platform independent way, you are supposed to use file.path
. It bugs me a little that, e.g.,
file.path("some dir", "some other dir", "my file")
is more characters and less readable than
"some dir/some other dir/my file"
I want to know if there are any platforms for which the second version will fail. Certainly the path separator (.Platform$file.sep
) is /
for Linux, Mac and Windows.
Are there any platforms (that R runs on) which have a different value of .Platform$file.sep
?
EDIT:
The the only current platforms from the Wikipedia list (thanks darioo) that don't use /
are OpenVMS, Stratus VOS and Symbian. The FAQ on R states that R is developed for
the Unix-like, Windows and Mac families of operating systems
So there is no official support for any of these platforms. I don't have a good feel for whether or not there's an army of hackers running R on their Nokia phones. Can you guesstimate a probability that anyone uses R on these systems?
A file separator is a character that is used to separate directory names that make up a path to a particular location. This character is operating system specific. On Microsoft Windows, it is a back-slash character (), e.g. C:myprojectmyfilesome.
The directory separator character separates subdirectories within the nested directory hierarchy. An optional filename. The directory separator character separates the file path and the filename.
pathSeparator is used to separate individual file paths in a list of file paths. Consider on windows, the PATH environment variable. You use a ; to separate the file paths so on Windows File.
Here is a list of operating systems with their file separators.
Compare it with the list of OS's on which R runs and you'll have a reference list.
Although, you'll probably stumble upon /
in 99% of situations.
\ is the traditional pathseperator in Windows. Some modern Windows Apps, API's handle both versions. But the old style is still the primary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With