Convert Windows paths to Linux style paths
On Tue, 12 Mar 2019 at 14:54, Malcolm Greene <python at bdurham.com> wrote:
> Looking for best practice technique for converting Windows style paths to Linux paths. Is there an os function or pathlib method that I'm missing or is it some combination of replacing Windows path separators with Linux path separators plus some other platform specific logic?
You need to explain what you mean by "converting". How would you want
"C:\Windows" to be converted? Or
"\\myserver\myshare\path\to\file.txt"? Or "\\?\D:\very long path"?
What if the path is too long for POSIX filename length limitations?
How do you want to handle Unicode? Do you care about case sensitivity
(for example, is it important to you whether filenames "foo" and "FOO"
map to the same file or not on Linux, given that they do on Windows)?
It's quite possible that your answer to any or all of these questions
are "I don't need to consider these cases". But we don't know which
cases matter to you unless you clarify, and the *general* problem of
"converting filenames" between operating systems is essentially
impossible, because semantics are radically different.