##// END OF EJS Templates
win32: backout 1a9ebc83a74c...
Steve Borho -
r21226:4898c37e stable
parent child Browse files
Show More
@@ -25,7 +25,6 b' import ctypes, errno, os, subprocess, ra'
25 25 # GetLastError
26 26 _ERROR_SUCCESS = 0
27 27 _ERROR_NO_MORE_FILES = 18
28 _ERROR_SHARING_VIOLATION = 32
29 28 _ERROR_INVALID_PARAMETER = 87
30 29 _ERROR_INSUFFICIENT_BUFFER = 122
31 30
@@ -61,9 +60,7 b' class _BY_HANDLE_FILE_INFORMATION(ctypes'
61 60
62 61 _OPEN_EXISTING = 3
63 62
64 _FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
65 63 _FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
66 _FILE_FLAG_DELETE_ON_CLOSE = 0x04000000
67 64
68 65 # SetFileAttributes
69 66 _FILE_ATTRIBUTE_NORMAL = 0x80
@@ -424,18 +421,11 b' def spawndetached(args):'
424 421 def unlink(f):
425 422 '''try to implement POSIX' unlink semantics on Windows'''
426 423
427 # If we can open f exclusively, no other processes must have open handles
428 # for it and we can expect its name will be deleted immediately when we
429 # close the handle unless we have another in the same process. We also
430 # expect we shall simply fail to open f if it is a directory.
431 fh = _kernel32.CreateFileA(f, 0, 0, None, _OPEN_EXISTING,
432 _FILE_FLAG_OPEN_REPARSE_POINT | _FILE_FLAG_DELETE_ON_CLOSE, None)
433 if fh != _INVALID_HANDLE_VALUE:
434 _kernel32.CloseHandle(fh)
435 return
436 error = _kernel32.GetLastError()
437 if error != _ERROR_SHARING_VIOLATION:
438 raise ctypes.WinError(error)
424 if os.path.isdir(f):
425 # use EPERM because it is POSIX prescribed value, even though
426 # unlink(2) on directories returns EISDIR on Linux
427 raise IOError(errno.EPERM,
428 "Unlinking directory not permitted: '%s'" % f)
439 429
440 430 # POSIX allows to unlink and rename open files. Windows has serious
441 431 # problems with doing that:
General Comments 0
You need to be logged in to leave comments. Login now