llvm.org GIT mirror llvm / 5e9b0f4
lit: make rm python 3 friendly (NFC) Add some alterations for python 3 compatibility. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357789 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 4 months ago
2 changed file(s) with 8 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
616616 # NOTE: use ctypes to access `SHFileOperationsW` on Windows to
617617 # use the NT style path to get access to long file paths which
618618 # cannot be removed otherwise.
619 from ctypes.wintypes import BOOL, HWND, LPCWSTR, POINTER, UINT, WORD
620 from ctypes import c_void_p, byref
619 from ctypes.wintypes import BOOL, HWND, LPCWSTR, UINT, WORD
620 from ctypes import addressof, byref, c_void_p, create_unicode_buffer
621621 from ctypes import Structure
622 from ctypes import windll, WinError
622 from ctypes import windll, WinError, POINTER
623623
624624 class SHFILEOPSTRUCTW(Structure):
625625 _fields_ = [
633633 ('lpszProgressTitle', LPCWSTR),
634634 ]
635635
636 FO_MOVE, FO_COPY, FO_DELETE, FO_RENAME = xrange(1, 5)
636 FO_MOVE, FO_COPY, FO_DELETE, FO_RENAME = range(1, 5)
637637
638638 FOF_SILENT = 4
639639 FOF_NOCONFIRMATION = 16
647647
648648 path = os.path.abspath(path)
649649
650 pFrom = create_unicode_buffer(path, len(path) + 2)
651 pFrom[len(path)] = pFrom[len(path) + 1] = '\0'
650652 operation = SHFILEOPSTRUCTW(wFunc=UINT(FO_DELETE),
651 pFrom=LPCWSTR(unicode(path + '\0')),
653 pFrom=LPCWSTR(addressof(pFrom)),
652654 fFlags=FOF_NO_UI)
653655 result = SHFileOperationW(byref(operation))
654656 if result:
148148 from ctypes import GetLastError, WinError
149149
150150 path = os.path.abspath(path)
151 NTPath = unicode(r'\\?\%s' % path)
151 NTPath = to_unicode(r'\\?\%s' % path)
152152 if not windll.kernel32.CreateDirectoryW(NTPath, None):
153153 raise WinError(GetLastError())
154154 else: