Interface
GioSeekable
Description [src]
interface Gio.Seekable : GObject.Object
GSeekable
is implemented by streams (implementations of
GInputStream
or GOutputStream
) that support seeking.
Seekable streams largely fall into two categories: resizable and fixed-size.
GSeekable
on fixed-sized streams is approximately the same as POSIX
lseek()
on a block device (for example: attempting to seek
past the end of the device is an error). Fixed streams typically cannot be truncated.
GSeekable
on resizable streams is approximately the same as POSIX
lseek()
on a normal file. Seeking past the end and writing
data will usually cause the stream to resize by introducing zero bytes.
Prerequisite
In order to implement Seekable, your type must inherit fromGObject
.
Instance methods
g_seekable_can_truncate
Tests if the length of the stream can be adjusted with g_seekable_truncate().
g_seekable_truncate
Sets the length of the stream to offset
. If the stream was previously
larger than offset
, the extra data is discarded. If the stream was
previously shorter than offset
, it is extended with NUL (‘\0’) bytes.
Interface structure
struct GioSeekableIface {
GTypeInterface g_iface;
goffset (* tell) (
GSeekable* seekable
);
gboolean (* can_seek) (
GSeekable* seekable
);
gboolean (* seek) (
GSeekable* seekable,
goffset offset,
GSeekType type,
GCancellable* cancellable,
GError** error
);
gboolean (* can_truncate) (
GSeekable* seekable
);
gboolean (* truncate_fn) (
GSeekable* seekable,
goffset offset,
GCancellable* cancellable,
GError** error
);
}
Provides an interface for implementing seekable functionality on I/O Streams.
Interface members
g_iface |
|
The parent interface. |
|
tell |
|
Tells the current location within a stream. |
|
can_seek |
|
Checks if seeking is supported by the stream. |
|
seek |
|
Seeks to a location within a stream. |
|
can_truncate |
|
Checks if truncation is supported by the stream. |
|
truncate_fn |
|
Truncates a stream. |
Virtual methods
Gio.Seekable.can_truncate
Tests if the length of the stream can be adjusted with g_seekable_truncate().
Gio.Seekable.truncate_fn
Sets the length of the stream to offset
. If the stream was previously
larger than offset
, the extra data is discarded. If the stream was
previously shorter than offset
, it is extended with NUL (‘\0’) bytes.