![]() |
![]() |
![]() |
libMirage Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Known Implementations |
#include <mirage-stream.h> MirageStream; struct MirageStreamInterface; const gchar * mirage_stream_get_filename (MirageStream *self
); gboolean mirage_stream_is_writable (MirageStream *self
); gboolean mirage_stream_move_file (MirageStream *self
,const gchar *new_filename
,GError **error
); gssize mirage_stream_read (MirageStream *self
,void *buffer
,gsize count
,GError **error
); gssize mirage_stream_write (MirageStream *self
,const void *buffer
,gsize count
,GError **error
); gboolean mirage_stream_seek (MirageStream *self
,goffset offset
,GSeekType type
,GError **error
); goffset mirage_stream_tell (MirageStream *self
); GInputStream * mirage_stream_get_g_input_stream (MirageStream *self
);
MirageStream is a basic unit of file access abstraction used in libMirage. It supports basic I/O operations, such as read, write, seek and tell.
Streams in libMirage are designed around the idea of filter stream chains, where several filter streams (MirageFilterStream) can be chained on top of a stream that abstracts direct access to the file (MirageFileStream).
struct MirageStreamInterface { GTypeInterface parent_iface; /* Interface methods */ const gchar *(*get_filename) (MirageStream *self); gboolean (*is_writable) (MirageStream *self); gboolean (*move_file) (MirageStream *self, const gchar *new_filename, GError **error); gssize (*read) (MirageStream *self, void *buffer, gsize count, GError **error); gssize (*write) (MirageStream *self, const void *buffer, gsize count, GError **error); gboolean (*seek) (MirageStream *self, goffset offset, GSeekType type, GError **error); goffset (*tell) (MirageStream *self); };
Provides an interface for implementing I/O streams.
the parent interface | |
retrieves the filename of the underlying file | |
determines whether the stream (chain) is writable | |
moves the underlying file | |
reads from stream | |
writes to stream | |
seeks to specified position in stream | |
retrieves current position in stream |
const gchar * mirage_stream_get_filename (MirageStream *self
);
Retrieves the name to file on which the stream is opened. If self
is
a filter stream in the filter stream chain, the filename is obtained from
the stream at the bottom of the chain.
|
a MirageFileStream |
Returns : |
pointer to a buffer containing the filename. The buffer belongs to the stream object and should not be modified. [transfer none] |
gboolean mirage_stream_is_writable (MirageStream *self
);
Queries the stream (chain) for write support. For the stream to be writable, the stream object implementation itself must support write operations, and any stream objects below it in the stream chain must also be writable.
|
a MirageFileStream |
Returns : |
TRUE if the stream (chain) is writable, FALSE if it is not. |
gboolean mirage_stream_move_file (MirageStream *self
,const gchar *new_filename
,GError **error
);
Attempts to move the file on top of which the stream (chain) is opened
to new_filename
. If supported, native move operations are used,
otherwise a copy + delete fallback is used.
|
a MirageFileStream |
|
the new filename. [in] |
|
location to store error, or NULL . [out][allow-none]
|
Returns : |
TRUE on success, FALSE on failure. |
gssize mirage_stream_read (MirageStream *self
,void *buffer
,gsize count
,GError **error
);
Attempts to read count
bytes from stream into the buffer starting at
buffer
. Will block during the operation.
|
a MirageFileStream |
|
a buffer to read data into. [in] |
|
number of bytes to read from stream. [in] |
|
location to store error, or NULL . [out][allow-none]
|
Returns : |
number of bytes read, or -1 on error, or 0 on end of file. |
gssize mirage_stream_write (MirageStream *self
,const void *buffer
,gsize count
,GError **error
);
Attempts to write count
bytes to stream from the buffer starting at
buffer
. Will block during the operation.
|
a MirageFileStream |
|
a buffer to write data from. [in] |
|
number of bytes to write to stream. [in] |
|
location to store error, or NULL . [out][allow-none]
|
Returns : |
number of bytes written, or -1 on error. |
gboolean mirage_stream_seek (MirageStream *self
,goffset offset
,GSeekType type
,GError **error
);
Seeks in the stream by the given offset
, modified by type
.
|
a MirageFileStream |
|
offset to seek. [in] |
|
seek type. [in] |
|
location to store error, or NULL . [out][allow-none]
|
Returns : |
TRUE on success, FALSE on failure. |
goffset mirage_stream_tell (MirageStream *self
);
Retrieves the current position within the stream.
|
a MirageFileStream |
Returns : |
the offset from the beginning of the stream. |
GInputStream * mirage_stream_get_g_input_stream (MirageStream *self
);
Constructs and returns a compatibility object inheriting a GInputStream. This is to allow regular GIO stream objects (for example, a GDataInputStream) to be chained on top of our filter stream chain.
|
a MirageFileStream |
Returns : |
a GInputStream. The reference should be
released using g_object_unref() when no longer needed. [transfer full]
|