[PATCH] D87732: [Support] Provide sys::path::guess_style

Adrian McCarthy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 08:45:03 PDT 2020


amccarth added a comment.

A big portability problem with the virtual file system (VFS) is that we now have paths that can legitimately be in a hybrid Windows/Posix style.  Be aware that some of the "guess-the-style" instances were modified to account for this.

It's _not_ true that you can _always_ substitute `/` for `\` in Windows paths.  It's true that most of the Win32 file handling APIs will accommodate non-native separators.  But Windows has multiple varieties of file paths, like UNC paths, where the backslashes are meaningful.  To bypass other Win32 API restrictions (like a relatively small MAX_PATH), many APIs now support a special prefix that tells the API to treat a path as an opaque sequence of wide chars that are passed down to the file system without alteration.  Those, too need to preserve blackslashes.  Finally, when file paths are presented in the UI, having the wrong separators hinders copy and pasting those paths into some common command line tools.

It's true that LLVM doesn't currently handle most of these cases where preserving the backslashes is important.  But the more we try to shoehorn all paths into the Posix model, the harder it will be to improve portability later.  I don't envy the VMS folks, where a proper path name can include a colon, square brackets, dot separators, and a semicolon.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87732/new/

https://reviews.llvm.org/D87732



More information about the llvm-commits mailing list