mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 21:43:09 +00:00
Improve all of the Windows-specific error reporting.
Also make the Windows function declarations more readable and consistent. Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
b517e200aa
commit
d07c45bdf4
@ -521,8 +521,10 @@ def get_available_space(whichdir, reserved_space):
|
|||||||
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
# <http://msdn.microsoft.com/en-us/library/aa363858%28v=vs.85%29.aspx>
|
# <http://msdn.microsoft.com/en-us/library/aa363858%28v=vs.85%29.aspx>
|
||||||
CreateFileW = WINFUNCTYPE(HANDLE, LPCWSTR, DWORD, DWORD, LPVOID, DWORD, DWORD, HANDLE) \
|
CreateFileW = WINFUNCTYPE(
|
||||||
(("CreateFileW", windll.kernel32))
|
HANDLE, LPCWSTR, DWORD, DWORD, LPVOID, DWORD, DWORD, HANDLE,
|
||||||
|
use_last_error=True
|
||||||
|
)(("CreateFileW", windll.kernel32))
|
||||||
|
|
||||||
GENERIC_WRITE = 0x40000000
|
GENERIC_WRITE = 0x40000000
|
||||||
FILE_SHARE_READ = 0x00000001
|
FILE_SHARE_READ = 0x00000001
|
||||||
@ -531,10 +533,16 @@ if sys.platform == "win32":
|
|||||||
INVALID_HANDLE_VALUE = 0xFFFFFFFF
|
INVALID_HANDLE_VALUE = 0xFFFFFFFF
|
||||||
|
|
||||||
# <http://msdn.microsoft.com/en-us/library/aa364439%28v=vs.85%29.aspx>
|
# <http://msdn.microsoft.com/en-us/library/aa364439%28v=vs.85%29.aspx>
|
||||||
FlushFileBuffers = WINFUNCTYPE(BOOL, HANDLE)(("FlushFileBuffers", windll.kernel32))
|
FlushFileBuffers = WINFUNCTYPE(
|
||||||
|
BOOL, HANDLE,
|
||||||
|
use_last_error=True
|
||||||
|
)(("FlushFileBuffers", windll.kernel32))
|
||||||
|
|
||||||
# <http://msdn.microsoft.com/en-us/library/ms724211%28v=vs.85%29.aspx>
|
# <http://msdn.microsoft.com/en-us/library/ms724211%28v=vs.85%29.aspx>
|
||||||
CloseHandle = WINFUNCTYPE(BOOL, HANDLE)(("CloseHandle", windll.kernel32))
|
CloseHandle = WINFUNCTYPE(
|
||||||
|
BOOL, HANDLE,
|
||||||
|
use_last_error=True
|
||||||
|
)(("CloseHandle", windll.kernel32))
|
||||||
|
|
||||||
# <http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/4465cafb-f4ed-434f-89d8-c85ced6ffaa8/>
|
# <http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/4465cafb-f4ed-434f-89d8-c85ced6ffaa8/>
|
||||||
def flush_volume(path):
|
def flush_volume(path):
|
||||||
@ -549,10 +557,10 @@ if sys.platform == "win32":
|
|||||||
None
|
None
|
||||||
)
|
)
|
||||||
if hVolume == INVALID_HANDLE_VALUE:
|
if hVolume == INVALID_HANDLE_VALUE:
|
||||||
raise WinError()
|
raise WinError(get_last_error())
|
||||||
|
|
||||||
if FlushFileBuffers(hVolume) == 0:
|
if FlushFileBuffers(hVolume) == 0:
|
||||||
raise WinError()
|
raise WinError(get_last_error())
|
||||||
|
|
||||||
CloseHandle(hVolume)
|
CloseHandle(hVolume)
|
||||||
else:
|
else:
|
||||||
@ -575,8 +583,7 @@ def reraise(wrapper):
|
|||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
# <https://msdn.microsoft.com/en-us/library/windows/desktop/aa365512%28v=vs.85%29.aspx>
|
# <https://msdn.microsoft.com/en-us/library/windows/desktop/aa365512%28v=vs.85%29.aspx>
|
||||||
ReplaceFileW = WINFUNCTYPE(
|
ReplaceFileW = WINFUNCTYPE(
|
||||||
BOOL,
|
BOOL, LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID,
|
||||||
LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID,
|
|
||||||
use_last_error=True
|
use_last_error=True
|
||||||
)(("ReplaceFileW", windll.kernel32))
|
)(("ReplaceFileW", windll.kernel32))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user