Whats the most clever (or preferably the right way) to handle different file system paths?
i.e
Windows
cd("Folder\\\\file.jl") #this becomes "\\"
Unix
cd("Folder/file.jl")
The only solution that comes to mind is declairing a global variable at runtime
@windows_only global slash = "\\"
@linux_only global slash = "/"
but that looks awfully dodgy
joinpath("Folder","file.jl")
should do the trick.
From the REPL ?joinpath
gives:
joinpath(parts...) -> AbstractString
Join path components into a full path. If some argument is an absolute
path, then prior components are dropped.
So, if needed more than two path parts can be joined as in:
joinpath("dir1","dir2","file1") == "dir1/dir2/file1"
(on a Linux machine)
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