gio.BufferedInputStream — Buffered Input Stream
class gio.BufferedInputStream(gio.FilterInputStream): |
Functions
def gio.buffered_input_stream_new_sized(size
)
+-- gobject.GObject +-- gio.InputStream +-- gio.FilterInputStream +-- gio.BufferedInputStream
|
gio.BufferedInputStream
implements gio.FilterInputStream
and provides for buffered reads.
By default,
gio.BufferedInputStream
's
buffer size is set at 4 kilobytes.
To create a buffered input stream, use
gio.BufferedInputStream
(),
or gio.buffered_input_stream_new_sized
()
to specify the buffer's size at construction.
To get the size of a buffer within a buffered input stream, use
get_buffer_size
().
To change the size of a buffered input stream's buffer, use
set_buffer_size
().
Note that the buffer's size cannot be reduced below the size of the data within the buffer.
gio.BufferedInputStream(base_stream
)
| a
gio.InputStream .
|
Returns : | a new
gio.InputStream
for the given base_stream.
|
Creates a new gio.InputStream
from the given base_stream, with a buffer set to the default size (4 kilobytes).
def fill(count
, cancellable
=None)
| the number of bytes that will be read from the stream. |
| optional
gio.Cancellable
object, None to ignore.
|
Returns : | the number of bytes read into stream's buffer, up to count, or -1 on error. |
The fill
() method tries to read count bytes
from the stream into the buffer. Will block during this read.
If count is zero, returns zero and does nothing. A value of count larger than G_MAXSSIZE will cause a gio.ERROR_INVALID_ARGUMENT error.
On success, the number of bytes read into the buffer is returned. It is not an error if this is not the same as the requested size, as it can happen e.g. near the end of a file. Zero is returned on end of file (or if count is zero), but never otherwise.
If count is -1 then the attempted read size is equal to the number of bytes that are required to fill the buffer.
If cancellable is not None
, then the operation can
be cancelled by triggering the cancellable object from another thread.
If the operation was cancelled, the error gio.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.
On error -1 is returned and error is set accordingly.
For the asynchronous, non-blocking, version of this function, see
gio.BufferedInputStream.fill_async
().
def fill_async(count
, callback
, io_priority
=glib.PRIORITY_DEFAULT, cancellable
=None, user_data
=None)
| the number of bytes that will be read from the stream. |
| a GAsyncReadyCallback to call when the request is satisfied. |
| the Glib Priority Constants of the request. |
| optional
gio.Cancellable
object, None to ignore. |
| the data to pass to callback function. |
The fill_async
() method reads data into stream's
buffer asynchronously, up to count size. io_priority can be used to
prioritize reads.
For the synchronous version of this function, see
gio.BufferedInputStream.fill
().
If cancellable is not None
, then the operation can be cancelled
by triggering the cancellable object from another thread. If the operation was
cancelled, the error gio.ERROR_CANCELLED will be set
If count is -1 then the attempted read size is equal to the number of bytes that are required to fill the buffer.
def fill_finish(result
)
| a gio.AsyncResult .
|
Returns : | the size of the read stream, or -1 on an error. |
The fill_finish
() method finishes an asynchronous
file append operation started with
gio.BufferedInputStream.fill_async
().
def get_available()
Returns : | size of the available stream. |
The get_available
() method gets the size of
the available data within the stream.
def get_buffer_size()
Returns : | the current buffer size. |
The get_buffer_size
() method gets the size
of the input buffer.
def read_byte(cancellable
=None)
| optional
gio.Cancellable
object, None to ignore.
|
Returns : | the byte read from the stream, or -1 on end of stream or error. |
The read_byte
() method tries to read a single
byte from the stream or the buffer. Will block during this read.
On success, the byte read from the stream is returned. On end of stream -1 is returned but it's not an exceptional error and error is not set.
If cancellable is not None
, then the operation can
be cancelled by triggering the cancellable object from another thread.
If the operation was cancelled, the error gio.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.
On error -1 is returned and error is set accordingly.
def buffered_input_stream_new_sized(size
)
| the requested buffer size. |
Returns : | A new
gio.InputStream .
|
The buffered_input_stream_new_sized
() function creates
a new gio.BufferedInputStream
from the given base_stream, with a buffer set to size.