gio.Seekable

gio.Seekable — Stream seeking interface.

Synopsis

class gio.Seekable(gobject.GInterface):
    def tell()
def can_seek()
def seek(offset, type=0, cancellable=None)
def can_truncate()
def truncate(offset, cancellable=None)

Ancestry

+-- gobject.GInterface
  +-- gio.Seekable

Known Implementation

gio.Seekable is implemented by gio.FileOutputStream, gio.MemoryInputStream, gio.FileInputStream and gio.MemoryOutputStream.

Description

gio.Seekable is implemented by streams (implementations of gio.InputStream or gio.OutputStream) that support seeking.

Methods

gio.Seekable.tell

    def tell()

Returns :

the offset from the beginning of the buffer

Tells the current position within the stream.

gio.Seekable.can_seek

    def can_seek()

Returns :

True if this gio.Seekable can be seeked with the seek() method, False if not.

The can_seek() method checks if the seek() can be used on this gio.Seekable.

gio.Seekable.seek

    def seek(offset, type=0, cancellable=None)

offset :

the offset that is added to the position determined by the type parameter.

type :

0=current position, 1=start of the file, 2=end of the file.

cancellable :

a gio.Cancellable or None.

Returns :

True on successful seek, False otherwise.

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

If cancellable is not None, then the operation can be cancelled by triggering the cancellable object from another thread.

gio.Seekable.can_truncate

    def can_truncate()

Returns :

True if this gio.Seekable can be truncated with the truncate() method, False if not.

The can_truncate() method checks if the truncate() can be used on this gio.Seekable.

gio.Seekable.truncate

    def truncate(offset, cancellable=None)

offset :

the offset at which the stream should be truncated

cancellable :

a gio.Cancellable or None.

Returns :

True if successful, False otherwise.

Truncates a stream with a given offset.

If cancellable is not None, then the operation can be cancelled by triggering the cancellable object from another thread.

If an operation was partially finished when the operation was cancelled the partial result will be returned, without an error.