##// END OF EJS Templates
win32: add a method to fetch the available pipe data size...
Matt Harbison -
r24652:232bf002 default
parent child Browse files
Show More
@@ -5,7 +5,7 b''
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 import ctypes, errno, os, subprocess, random
8 import ctypes, errno, msvcrt, os, subprocess, random
9
9
10 _kernel32 = ctypes.windll.kernel32
10 _kernel32 = ctypes.windll.kernel32
11 _advapi32 = ctypes.windll.advapi32
11 _advapi32 = ctypes.windll.advapi32
@@ -26,6 +26,7 b' import ctypes, errno, os, subprocess, ra'
26 _ERROR_SUCCESS = 0
26 _ERROR_SUCCESS = 0
27 _ERROR_NO_MORE_FILES = 18
27 _ERROR_NO_MORE_FILES = 18
28 _ERROR_INVALID_PARAMETER = 87
28 _ERROR_INVALID_PARAMETER = 87
29 _ERROR_BROKEN_PIPE = 109
29 _ERROR_INSUFFICIENT_BUFFER = 122
30 _ERROR_INSUFFICIENT_BUFFER = 122
30
31
31 # WPARAM is defined as UINT_PTR (unsigned type)
32 # WPARAM is defined as UINT_PTR (unsigned type)
@@ -211,6 +212,10 b' except AttributeError:'
211 _kernel32.CreateToolhelp32Snapshot.argtypes = [_DWORD, _DWORD]
212 _kernel32.CreateToolhelp32Snapshot.argtypes = [_DWORD, _DWORD]
212 _kernel32.CreateToolhelp32Snapshot.restype = _BOOL
213 _kernel32.CreateToolhelp32Snapshot.restype = _BOOL
213
214
215 _kernel32.PeekNamedPipe.argtypes = [_HANDLE, ctypes.c_void_p, _DWORD,
216 ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p]
217 _kernel32.PeekNamedPipe.restype = _BOOL
218
214 _kernel32.Process32First.argtypes = [_HANDLE, ctypes.c_void_p]
219 _kernel32.Process32First.argtypes = [_HANDLE, ctypes.c_void_p]
215 _kernel32.Process32First.restype = _BOOL
220 _kernel32.Process32First.restype = _BOOL
216
221
@@ -260,6 +265,19 b' def samedevice(path1, path2):'
260 res2 = _getfileinfo(path2)
265 res2 = _getfileinfo(path2)
261 return res1.dwVolumeSerialNumber == res2.dwVolumeSerialNumber
266 return res1.dwVolumeSerialNumber == res2.dwVolumeSerialNumber
262
267
268 def peekpipe(pipe):
269 handle = msvcrt.get_osfhandle(pipe.fileno())
270 avail = _DWORD()
271
272 if not _kernel32.PeekNamedPipe(handle, None, 0, None, ctypes.byref(avail),
273 None):
274 err = _kernel32.GetLastError()
275 if err == _ERROR_BROKEN_PIPE:
276 return 0
277 raise ctypes.WinError(err)
278
279 return avail.value
280
263 def testpid(pid):
281 def testpid(pid):
264 '''return True if pid is still running or unable to
282 '''return True if pid is still running or unable to
265 determine, False otherwise'''
283 determine, False otherwise'''
General Comments 0
You need to be logged in to leave comments. Login now