Mirage.Stream

g GObject.GInterface GObject.GInterface Mirage.Stream Mirage.Stream GObject.GInterface->Mirage.Stream

Implementations:

Mirage.FileStream, Mirage.FilterStream

Methods

get_filename ()

get_g_input_stream ()

is_writable ()

move_file (new_filename)

read (buffer, count)

seek (offset, type)

tell ()

write (buffer, count)

Virtual Methods

do_get_filename ()

do_is_writable ()

do_move_file (new_filename)

do_read (buffer, count)

do_seek (offset, type)

do_tell ()

do_write (buffer, count)

Properties

None

Signals

None

Fields

None

Class Details

class Mirage.Stream
Bases:

GObject.GInterface

Structure:

Mirage.StreamInterface

A stream object.

get_filename()
Returns:

pointer to a buffer containing the filename. The buffer belongs to the stream object and should not be modified.

Return type:

str

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.

get_g_input_stream()
Returns:

a Gio.InputStream. The reference should be released using GObject.Object.unref() when no longer needed.

Return type:

Gio.InputStream

Constructs and returns a compatibility object inheriting a Gio.InputStream. This is to allow regular GIO stream objects (for example, a Gio.DataInputStream) to be chained on top of our filter stream chain.

is_writable()
Returns:

True if the stream (chain) is writable, False if it is not.

Return type:

bool

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.

move_file(new_filename)
Parameters:

new_filename (str) – the new filename

Raises:

GLib.Error

Returns:

True on success, False on failure.

Return type:

bool

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.

read(buffer, count)
Parameters:
  • buffer (object or None) – a buffer to read data into

  • count (int) – number of bytes to read from stream

Raises:

GLib.Error

Returns:

number of bytes read, or -1 on error, or 0 on end of file.

Return type:

int

Attempts to read count bytes from stream into the buffer starting at buffer. Will block during the operation.

seek(offset, type)
Parameters:
Raises:

GLib.Error

Returns:

True on success, False on failure.

Return type:

bool

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

tell()
Returns:

the offset from the beginning of the stream.

Return type:

int

Retrieves the current position within the stream.

write(buffer, count)
Parameters:
  • buffer (object or None) – a buffer to write data from

  • count (int) – number of bytes to write to stream

Raises:

GLib.Error

Returns:

number of bytes written, or -1 on error.

Return type:

int

Attempts to write count bytes to stream from the buffer starting at buffer. Will block during the operation.

do_get_filename() virtual
Returns:

pointer to a buffer containing the filename. The buffer belongs to the stream object and should not be modified.

Return type:

str

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.

do_is_writable() virtual
Returns:

True if the stream (chain) is writable, False if it is not.

Return type:

bool

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.

do_move_file(new_filename) virtual
Parameters:

new_filename (str) – the new filename

Returns:

True on success, False on failure.

Return type:

bool

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.

do_read(buffer, count) virtual
Parameters:
  • buffer (object or None) – a buffer to read data into

  • count (int) – number of bytes to read from stream

Returns:

number of bytes read, or -1 on error, or 0 on end of file.

Return type:

int

Attempts to read count bytes from stream into the buffer starting at buffer. Will block during the operation.

do_seek(offset, type) virtual
Parameters:
Returns:

True on success, False on failure.

Return type:

bool

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

do_tell() virtual
Returns:

the offset from the beginning of the stream.

Return type:

int

Retrieves the current position within the stream.

do_write(buffer, count) virtual
Parameters:
  • buffer (object or None) – a buffer to write data from

  • count (int) – number of bytes to write to stream

Returns:

number of bytes written, or -1 on error.

Return type:

int

Attempts to write count bytes to stream from the buffer starting at buffer. Will block during the operation.