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_seek

Tests if the stream supports the GSeekableIface.

g_seekable_can_truncate

Tests if the length of the stream can be adjusted with g_seekable_truncate().

g_seekable_seek

Seeks in the stream by the given offset, modified by type.

g_seekable_tell

Tells the current position within the stream.

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
GTypeInterface
 

The parent interface.

tell
goffset (* tell) (
    GSeekable* seekable
  )
 

Tells the current location within a stream.

can_seek
gboolean (* can_seek) (
    GSeekable* seekable
  )
 

Checks if seeking is supported by the stream.

seek
gboolean (* seek) (
    GSeekable* seekable,
    goffset offset,
    GSeekType type,
    GCancellable* cancellable,
    GError** error
  )
 

Seeks to a location within a stream.

can_truncate
gboolean (* can_truncate) (
    GSeekable* seekable
  )
 

Checks if truncation is supported by the stream.

truncate_fn
gboolean (* truncate_fn) (
    GSeekable* seekable,
    goffset offset,
    GCancellable* cancellable,
    GError** error
  )
 

Truncates a stream.

Virtual methods

Gio.Seekable.can_seek

Tests if the stream supports the GSeekableIface.

Gio.Seekable.can_truncate

Tests if the length of the stream can be adjusted with g_seekable_truncate().

Gio.Seekable.seek

Seeks in the stream by the given offset, modified by type.

Gio.Seekable.tell

Tells the current position within the stream.

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.