Esempio n. 1
0
 def readall( self ):
     """Reads all the data of the file until EOF."""
     self.__check_not_closed()
     size = _win32kernel.LARGE_INTEGER()
     _win32kernel.check_io_succeed(
         _win32kernel.GetFileSizeEx( self.__handle, ctypes.byref(size) ) )
     return self.read( size.value )
Esempio n. 2
0
 def readall(self):
     """Reads all the data of the file until EOF."""
     self.__check_not_closed()
     size = _win32kernel.LARGE_INTEGER()
     _win32kernel.check_io_succeed(
         _win32kernel.GetFileSizeEx(self.__handle, ctypes.byref(size)))
     return self.read(size.value)
Esempio n. 3
0
 def flush(self):
     """Flush pending write to disk. If file is a pipe, wait for client to read all data.
     """
     self.__check_not_closed()
     # Notes: FlushFileBuffers will fail if file was not open with
     # GENERIC_WRITE access
     if self.__writable:
         _win32kernel.check_io_succeed(
             _win32kernel.FlushFileBuffers(self.__handle))
Esempio n. 4
0
 def seek(self, offset, whence=SEEK_SET):
     self.__check_not_closed()
     seek_method = _WIN32_SEEK[whence]
     new_pos = _win32kernel.LARGE_INTEGER()
     _win32kernel.check_io_succeed(
         _win32kernel.SetFilePointerEx(self.__handle,
                                       _win32kernel.LARGE_INTEGER(offset),
                                       ctypes.byref(new_pos), seek_method))
     return new_pos.value
Esempio n. 5
0
 def flush( self ):
     """Flush pending write to disk. If file is a pipe, wait for client to read all data.
     """
     self.__check_not_closed()
     # Notes: FlushFileBuffers will fail if file was not open with
     # GENERIC_WRITE access
     if self.__writable: 
         _win32kernel.check_io_succeed(
             _win32kernel.FlushFileBuffers( self.__handle ) )
Esempio n. 6
0
 def seek( self, offset, whence=SEEK_SET):
     self.__check_not_closed()
     seek_method = _WIN32_SEEK[whence]
     new_pos = _win32kernel.LARGE_INTEGER()
     _win32kernel.check_io_succeed(
         _win32kernel.SetFilePointerEx( self.__handle,
                           _win32kernel.LARGE_INTEGER( offset ),
                           ctypes.byref( new_pos ),
                           seek_method ) )
     return new_pos.value
Esempio n. 7
0
 def truncate(self, size=None):
     self.__check_not_closed()
     if size is not None:
         self.seek(size, whence=SEEK_SET)
     # Truncate file at current position
     _win32kernel.check_io_succeed(SetEndOfFile(self.__handle))
Esempio n. 8
0
 def truncate( self, size=None ):
     self.__check_not_closed()
     if size is not None:
         self.seek( size, whence=SEEK_SET )
     # Truncate file at current position
     _win32kernel.check_io_succeed( SetEndOfFile( self.__handle ) )