):
gio.BufferedInputStream(base_stream
)
def fill(count
, cancellable
=None)
def fill_async(count
, callback
, io_priority
=glib.PRIORITY_DEFAULT, cancellable
=None, user_data
=None)
def fill_finish(result
)
def get_available()
def get_buffer_size()
def read_byte(cancellable
=None)
def set_buffer_size(size
)
Functions
def gio.buffered_input_stream_new_sized(size
)
Methods
gio.BufferedInputStream.fill
def fill(count
, cancellable
=None)
count :
| the number of bytes that will be read from the stream.
|
cancellable :
| 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
().
gio.BufferedInputStream.fill_async
def fill_async(count
, callback
, io_priority
=glib.PRIORITY_DEFAULT, cancellable
=None, user_data
=None)
count :
| the number of bytes that will be read from the stream.
|
callback :
| a GAsyncReadyCallback to call when the request is satisfied.
|
io_priority :
| the
Glib Priority Constants
of the request.
|
cancellable :
| optional
gio.Cancellable
object, None to ignore. |
user_data :
| 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.
gio.BufferedInputStream.fill_finish
def fill_finish(result
)
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
().
gio.BufferedInputStream.get_available
def get_available()
Returns : | size of the available stream.
|
The get_available
() method gets the size of
the available data within the stream.
gio.BufferedInputStream.get_buffer_size
def get_buffer_size()
Returns : | the current buffer size.
|
The get_buffer_size
() method gets the size
of the input buffer.
gio.BufferedInputStream.read_byte
def read_byte(cancellable
=None)
cancellable :
| 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.
gio.BufferedInputStream.set_buffer_size
def set_buffer_size(size
)
size :
| the new buffer size.
|
The set_buffer_size
() method sets the size
of the internal buffer of stream to size, or to the size of the contents
of the buffer. The buffer can never be resized smaller than its current contents.