def close(cls, fp): """ :type fp: WindowsFile :rtype: bool """ if fp.map_view: WindowsInterop.unmap_view_of_file(fp.map_view) if fp.file_map: WindowsInterop.close_handle(fp.file_map) return bool(WindowsInterop.close_handle(fp.handle))
def get_path(cls, fp): """ :type fp: WindowsFile: :rtype: str """ if not fp.file_map: fp.file_map = WindowsInterop.create_file_mapping(fp.handle, WindowsASIO.Protection.READONLY) if not fp.map_view: fp.map_view = WindowsInterop.map_view_of_file(fp.file_map, WindowsASIO.FileMapAccess.READ, 1) file_name = WindowsInterop.get_mapped_file_name(fp.map_view) return file_name
def read(cls, fp, buf_size=DEFAULT_BUFFER_SIZE): """ :type fp: WindowsFile :type buf_size: int :rtype: str """ return WindowsInterop.read_file(fp.handle, buf_size)
def seek(cls, fp, offset, origin): """ :type fp: WindowsFile :type offset: int :type origin: int :rtype: int """ return WindowsInterop.set_file_pointer( fp.handle, offset, origin )
def open(cls, file_path, parameters=None): """ :type file_path: str :rtype: WindowsFile """ if not parameters: parameters = {} return WindowsFile(WindowsInterop.create_file( file_path, parameters.get('desired_access', WindowsASIO.GenericAccess.READ), parameters.get('share_mode', WindowsASIO.ShareMode.ALL), parameters.get('creation_disposition', WindowsASIO.CreationDisposition.OPEN_EXISTING), parameters.get('flags_and_attributes', NULL) ))
def get_size(cls, fp): """ :type fp: WindowsFile: :rtype: int """ return WindowsInterop.get_file_size(fp.handle)