|  |  |  | GIO Reference Manual |  | 
|---|---|---|---|---|
| Top | Description | Object Hierarchy | Prerequisites | Known Implementations | ||||
#include <gio/gio.h>
                    GSeekable;
struct              GSeekableIface;
goffset             g_seekable_tell                     (GSeekable *seekable);
gboolean            g_seekable_can_seek                 (GSeekable *seekable);
gboolean            g_seekable_seek                     (GSeekable *seekable,
                                                         goffset offset,
                                                         GSeekType type,
                                                         GCancellable *cancellable,
                                                         GError **error);
gboolean            g_seekable_can_truncate             (GSeekable *seekable);
gboolean            g_seekable_truncate                 (GSeekable *seekable,
                                                         goffset offset,
                                                         GCancellable *cancellable,
                                                         GError **error);
GSeekable is implemented by GFileIOStream, GFileInputStream, GFileOutputStream, GMemoryInputStream and GMemoryOutputStream.
GSeekable is implemented by streams (implementations of GInputStream or GOutputStream) that support seeking.
struct GSeekableIface {
  GTypeInterface g_iface;
  /* Virtual Table */
  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);
  /* TODO: Async seek/truncate */
};
Provides an interface for implementing seekable functionality on I/O Streams.
| GTypeInterface  | The parent interface. | 
| Tells the current location within a stream. | |
| Checks if seeking is supported by the stream. | |
| Seeks to a location within a stream. | |
| Chekcs if truncation is suppored by the stream. | |
| Truncates a stream. | 
goffset             g_seekable_tell                     (GSeekable *seekable);
Tells the current position within the stream.
| 
 | a GSeekable. | 
| Returns : | the offset from the beginning of the buffer. | 
gboolean            g_seekable_can_seek                 (GSeekable *seekable);
Tests if the stream supports the GSeekableIface.
gboolean g_seekable_seek (GSeekable *seekable,goffset offset,GSeekType type,GCancellable *cancellable,GError **error);
Seeks in the stream by the given offset, modified by type.
If cancellable is not NULL, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error G_IO_ERROR_CANCELLED will be returned.
| 
 | a GSeekable. | 
| 
 | a goffset. | 
| 
 | a GSeekType. | 
| 
 | optional GCancellable object, NULLto ignore. [allow-none] | 
| 
 | a GError location to store the error occurring, or NULLto
ignore. | 
| Returns : | TRUEif successful. If an error
has occurred, this function will returnFALSEand seterrorappropriately if present. | 
gboolean            g_seekable_can_truncate             (GSeekable *seekable);
Tests if the stream can be truncated.
gboolean g_seekable_truncate (GSeekable *seekable,goffset offset,GCancellable *cancellable,GError **error);
Truncates a stream with a given offset.
If cancellable is not NULL, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error G_IO_ERROR_CANCELLED will be returned. If an
operation was partially finished when the operation was cancelled the
partial result will be returned, without an error.
Virtual: truncate_fn
| 
 | a GSeekable. | 
| 
 | a goffset. | 
| 
 | optional GCancellable object, NULLto ignore. [allow-none] | 
| 
 | a GError location to store the error occurring, or NULLto
ignore. | 
| Returns : | TRUEif successful. If an error
has occurred, this function will returnFALSEand seterrorappropriately if present. |