Top | ![]() |
![]() |
![]() |
![]() |
gboolean | mirage_file_filter_can_handle_data_format () |
void | mirage_file_filter_generate_info () |
const MirageFileFilterInfo * | mirage_file_filter_get_info () |
goffset | mirage_file_filter_get_position () |
void | mirage_file_filter_info_copy () |
void | mirage_file_filter_info_free () |
void | mirage_file_filter_set_file_size () |
MirageFileFilter is a basic unit of file access abstraction used in libMirage. It inherits from GFilterInputStream and implements GSeekable interface.
When opening a file with libMirage, mirage_context_create_file_stream()
function should be used. It creates a chain of MirageFileFilter objects
on top of a GFileInputStream, and returns the top object on the chain.
This allows transparent access to, for example, compressed data stored
in the file.
There are two ways to implement a MirageFileFilter. For full control
over the logic for reading from parts and managing position in the
stream, use "full interface", which requires implementation of three
virtual functions: read, seek and tell. The second option is to use
"simplified interface", which provides framework for stream position
management and reading logic, and requires that file filter implements
partial_read function. Additionally, it requires that file filter
implementation sets the file stream size using
mirage_file_filter_set_file_size()
function. In partial_read, the
current position in the stream, which is managed by the framework, can
be obtained using mirage_file_filter_get_position()
.
gboolean mirage_file_filter_can_handle_data_format (MirageFileFilter *self
,GError **error
);
Checks whether file filter can handle data stored in underyling stream.
void mirage_file_filter_generate_info (MirageFileFilter *self
,const gchar *id
,const gchar *name
,gint num_types
,...
);
Generates file filter information from the input fields. It is intended as a function for creating file filter information in file filter implementations.
const MirageFileFilterInfo *
mirage_file_filter_get_info (MirageFileFilter *self
);
Retrieves file filter information.
goffset
mirage_file_filter_get_position (MirageFileFilter *self
);
Retrieves position in the stream.
This function is intented for use in file filter implementations that are based on the simplified interface. It should be used by the implementation's partial_read function to determine position to read from without having to worry about position management and update.
void mirage_file_filter_info_copy (const MirageFileFilterInfo *info
,MirageFileFilterInfo *dest
);
Copies parser information from info
to dest
.
info |
a MirageFileFilterInfo to copy data from. |
[in] |
dest |
a MirageFileFilterInfo to copy data to. |
[in] |
void
mirage_file_filter_info_free (MirageFileFilterInfo *info
);
Frees the allocated fields in info
(but not the structure itself!).
void mirage_file_filter_set_file_size (MirageFileFilter *self
,gsize size
);
Sets size of the stream.
This function is intented for use in file filter implementations that are based on the simplified interface. It should be used by the implementation to set the stream size during stream parsing; the set stream size is then used by the read function that is implemented by the simplified interface.
struct MirageFileFilter;
All the fields in the MirageFileFilter structure are private to the MirageFileFilter implementation and should never be accessed directly.
struct MirageFileFilterClass { GFilterInputStreamClass parent_class; /* Class members */ gboolean (*can_handle_data_format) (MirageFileFilter *self, GError **error); /* Functions reimplemented from GInputStream: */ gssize (*read) (MirageFileFilter *self, void *buffer, gsize count, GError **error); /* Functions reimplemented from GSeekable: */ goffset (*tell) (MirageFileFilter *self); gboolean (*seek) (MirageFileFilter *self, goffset offset, GSeekType type, GError **error); /* Simplified interface */ gssize (*partial_read) (MirageFileFilter *self, void *buffer, gsize count); };
The class structure for the MirageFileFilter type.
struct MirageFileFilterInfo { gchar *id; gchar *name; gchar **description; gchar **mime_type; };
A structure containing file filter information. It can be obtained
with call to mirage_file_filter_get_info()
.