Commit c2ecf0ef by willmcgugan

Fixed an issue in Py2.5, which doesnn't have wintypes.LPVOID defined

parent a82b7c12
...@@ -17,6 +17,12 @@ import ctypes ...@@ -17,6 +17,12 @@ import ctypes
import ctypes.wintypes import ctypes.wintypes
import traceback import traceback
try:
LPVOID = ctypes.wintypes.LPVOID
except AttributeError:
# LPVOID wasn't defined in Py2.5, guess it was introduced in Py2.6
LPVOID = ctypes.c_void_p
from fs.errors import * from fs.errors import *
from fs.path import * from fs.path import *
from fs.watch import * from fs.watch import *
...@@ -74,11 +80,11 @@ def _errcheck_dword(value,func,args): ...@@ -74,11 +80,11 @@ def _errcheck_dword(value,func,args):
class OVERLAPPED(ctypes.Structure): class OVERLAPPED(ctypes.Structure):
_fields_ = [('Internal', ctypes.wintypes.LPVOID), _fields_ = [('Internal', LPVOID),
('InternalHigh', ctypes.wintypes.LPVOID), ('InternalHigh', LPVOID),
('Offset', ctypes.wintypes.DWORD), ('Offset', ctypes.wintypes.DWORD),
('OffsetHigh', ctypes.wintypes.DWORD), ('OffsetHigh', ctypes.wintypes.DWORD),
('Pointer', ctypes.wintypes.LPVOID), ('Pointer', LPVOID),
('hEvent', ctypes.wintypes.HANDLE), ('hEvent', ctypes.wintypes.HANDLE),
] ]
...@@ -91,13 +97,13 @@ ReadDirectoryChangesW.restype = ctypes.wintypes.BOOL ...@@ -91,13 +97,13 @@ ReadDirectoryChangesW.restype = ctypes.wintypes.BOOL
ReadDirectoryChangesW.errcheck = _errcheck_bool ReadDirectoryChangesW.errcheck = _errcheck_bool
ReadDirectoryChangesW.argtypes = ( ReadDirectoryChangesW.argtypes = (
ctypes.wintypes.HANDLE, # hDirectory ctypes.wintypes.HANDLE, # hDirectory
ctypes.wintypes.LPVOID, # lpBuffer LPVOID, # lpBuffer
ctypes.wintypes.DWORD, # nBufferLength ctypes.wintypes.DWORD, # nBufferLength
ctypes.wintypes.BOOL, # bWatchSubtree ctypes.wintypes.BOOL, # bWatchSubtree
ctypes.wintypes.DWORD, # dwNotifyFilter ctypes.wintypes.DWORD, # dwNotifyFilter
ctypes.POINTER(ctypes.wintypes.DWORD), # lpBytesReturned ctypes.POINTER(ctypes.wintypes.DWORD), # lpBytesReturned
ctypes.POINTER(OVERLAPPED), # lpOverlapped ctypes.POINTER(OVERLAPPED), # lpOverlapped
ctypes.wintypes.LPVOID #FileIOCompletionRoutine # lpCompletionRoutine LPVOID #FileIOCompletionRoutine # lpCompletionRoutine
) )
CreateFileW = ctypes.windll.kernel32.CreateFileW CreateFileW = ctypes.windll.kernel32.CreateFileW
...@@ -107,7 +113,7 @@ CreateFileW.argtypes = ( ...@@ -107,7 +113,7 @@ CreateFileW.argtypes = (
ctypes.wintypes.LPCWSTR, # lpFileName ctypes.wintypes.LPCWSTR, # lpFileName
ctypes.wintypes.DWORD, # dwDesiredAccess ctypes.wintypes.DWORD, # dwDesiredAccess
ctypes.wintypes.DWORD, # dwShareMode ctypes.wintypes.DWORD, # dwShareMode
ctypes.wintypes.LPVOID, # lpSecurityAttributes LPVOID, # lpSecurityAttributes
ctypes.wintypes.DWORD, # dwCreationDisposition ctypes.wintypes.DWORD, # dwCreationDisposition
ctypes.wintypes.DWORD, # dwFlagsAndAttributes ctypes.wintypes.DWORD, # dwFlagsAndAttributes
ctypes.wintypes.HANDLE # hTemplateFile ctypes.wintypes.HANDLE # hTemplateFile
...@@ -123,7 +129,7 @@ CreateEvent = ctypes.windll.kernel32.CreateEventW ...@@ -123,7 +129,7 @@ CreateEvent = ctypes.windll.kernel32.CreateEventW
CreateEvent.restype = ctypes.wintypes.HANDLE CreateEvent.restype = ctypes.wintypes.HANDLE
CreateEvent.errcheck = _errcheck_handle CreateEvent.errcheck = _errcheck_handle
CreateEvent.argtypes = ( CreateEvent.argtypes = (
ctypes.wintypes.LPVOID, # lpEventAttributes LPVOID, # lpEventAttributes
ctypes.wintypes.BOOL, # bManualReset ctypes.wintypes.BOOL, # bManualReset
ctypes.wintypes.BOOL, # bInitialState ctypes.wintypes.BOOL, # bInitialState
ctypes.wintypes.LPCWSTR, #lpName ctypes.wintypes.LPCWSTR, #lpName
...@@ -151,7 +157,7 @@ CreateIoCompletionPort.errcheck = _errcheck_handle ...@@ -151,7 +157,7 @@ CreateIoCompletionPort.errcheck = _errcheck_handle
CreateIoCompletionPort.argtypes = ( CreateIoCompletionPort.argtypes = (
ctypes.wintypes.HANDLE, # FileHandle ctypes.wintypes.HANDLE, # FileHandle
ctypes.wintypes.HANDLE, # ExistingCompletionPort ctypes.wintypes.HANDLE, # ExistingCompletionPort
ctypes.wintypes.LPVOID, # CompletionKey LPVOID, # CompletionKey
ctypes.wintypes.DWORD, # NumberOfConcurrentThreads ctypes.wintypes.DWORD, # NumberOfConcurrentThreads
) )
...@@ -160,8 +166,8 @@ GetQueuedCompletionStatus.restype = ctypes.wintypes.BOOL ...@@ -160,8 +166,8 @@ GetQueuedCompletionStatus.restype = ctypes.wintypes.BOOL
GetQueuedCompletionStatus.errcheck = _errcheck_bool GetQueuedCompletionStatus.errcheck = _errcheck_bool
GetQueuedCompletionStatus.argtypes = ( GetQueuedCompletionStatus.argtypes = (
ctypes.wintypes.HANDLE, # CompletionPort ctypes.wintypes.HANDLE, # CompletionPort
ctypes.wintypes.LPVOID, # lpNumberOfBytesTransferred LPVOID, # lpNumberOfBytesTransferred
ctypes.wintypes.LPVOID, # lpCompletionKey LPVOID, # lpCompletionKey
ctypes.POINTER(OVERLAPPED), # lpOverlapped ctypes.POINTER(OVERLAPPED), # lpOverlapped
ctypes.wintypes.DWORD, # dwMilliseconds ctypes.wintypes.DWORD, # dwMilliseconds
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment