[lit] [windows] Make sure to convert all path separators to backslashes in NT style \\?\... paths

E.g. the mingw python distributed in msys2 (the mingw one, which is a
normal win32 application and doesn't use the msys2 runtime itself),
despite being a normal win32 python, still uses forward slashes. This
works fine for other cases (many, but not all), but when constructing a
raw NT path, all path separators must be backslashes.

Differential Revision: https://reviews.llvm.org/D71490
This commit is contained in:
Martin Storsjö 2019-12-13 21:28:19 +00:00
parent ee0a3b5c77
commit d39510ec1c
1 changed files with 4 additions and 0 deletions

View File

@ -151,6 +151,10 @@ def mkdir(path):
from ctypes import GetLastError, WinError
path = os.path.abspath(path)
# Make sure that the path uses backslashes here, in case
# python would have happened to use forward slashes, as the
# NT path format only supports backslashes.
path = path.replace('/', '\\')
NTPath = to_unicode(r'\\?\%s' % path)
if not windll.kernel32.CreateDirectoryW(NTPath, None):
raise WinError(GetLastError())