def consume(self, amount):
'''Consume ``amount`` bytes from the given provider.'''
resultBuffer = (ctypes.c_char*amount)()
amount,resultAmount = ctypes.c_ulong(amount),ctypes.c_ulong(amount)
result = k32.ReadFile(
self.handle, ctypes.byref(resultBuffer),
amount, ctypes.byref(resultAmount),
None
)
if (result == 0) or (resultAmount.value == 0 and amount > 0):
e = OSError(win32error.getLastErrorTuple())
raise error.ConsumeError(self,self.offset,amount,resultAmount.value, exception=e)
if resultAmount.value == amount:
self.offset += resultAmount.value
return str(resultBuffer.raw)
评论列表
文章目录