Gio.BufferedInputStream¶
- Subclasses:
Methods¶
- Inherited:
Gio.FilterInputStream (3), Gio.InputStream (19), GObject.Object (37), Gio.Seekable (5)
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/c |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gio.BufferedInputStream(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Buffered input stream implements
Gio.FilterInputStream
and provides for buffered reads.By default,
GBufferedInputStream
’s buffer size is set at 4 kilobytes.To create a buffered input stream, use [ctor`Gio`.BufferedInputStream.new], or [ctor`Gio`.BufferedInputStream.new_sized] to specify the buffer’s size at construction.
To get the size of a buffer within a buffered input stream, use [method`Gio`.BufferedInputStream.get_buffer_size]. To change the size of a buffered input stream’s buffer, use [method`Gio`.BufferedInputStream.set_buffer_size]. Note that the buffer’s size cannot be reduced below the size of the data within the buffer.
- classmethod new(base_stream)[source]¶
- Parameters:
base_stream (
Gio.InputStream
) – aGio.InputStream
- Returns:
a
Gio.InputStream
for the given base_stream.- Return type:
Creates a new
Gio.InputStream
from the given base_stream, with a buffer set to the default size (4 kilobytes).
- classmethod new_sized(base_stream, size)[source]¶
- Parameters:
base_stream (
Gio.InputStream
) – aGio.InputStream
size (
int
) – a #gsize
- Returns:
- Return type:
Creates a new
Gio.BufferedInputStream
from the given base_stream, with a buffer set to size.
- fill(count, cancellable)[source]¶
- Parameters:
count (
int
) – the number of bytes that will be read from the streamcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore
- Raises:
- Returns:
the number of bytes read into self's buffer, up to count, or -1 on error.
- Return type:
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
GObject.G_MAXSSIZE
will cause aGio.IOErrorEnum.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 errorGio.IOErrorEnum.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
().
- fill_async(count, io_priority, cancellable, callback, *user_data)[source]¶
- Parameters:
count (
int
) – the number of bytes that will be read from the streamio_priority (
int
) – the I/O priority of the requestcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
objectcallback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
Reads data into self'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 count is -1 then the attempted read size is equal to the number of bytes that are required to fill the buffer.
- fill_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
a #gssize of the read stream, or
-1
on an error.- Return type:
Finishes an asynchronous read.
- get_available()[source]¶
- Returns:
size of the available stream.
- Return type:
Gets the size of the available data within the stream.
- get_buffer_size()[source]¶
- Returns:
the current buffer size.
- Return type:
Gets the size of the input buffer.
- peek(buffer, offset)[source]¶
- Parameters:
- Returns:
a #gsize of the number of bytes peeked, or -1 on error.
- Return type:
Peeks in the buffer, copying data of size count into buffer, offset offset bytes.
- peek_buffer()[source]¶
- Returns:
read-only buffer
- Return type:
Returns the buffer with the currently available bytes. The returned buffer must not be modified and will become invalid when reading from the stream or filling the buffer.
- read_byte(cancellable)[source]¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore- Raises:
- Returns:
the byte read from the self, or -1 on end of stream or error.
- Return type:
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 errorGio.IOErrorEnum.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.
- set_buffer_size(size)[source]¶
- Parameters:
size (
int
) – a #gsize
Sets the size of the internal buffer of self to size, or to the size of the contents of the buffer. The buffer can never be resized smaller than its current contents.
- do_fill(count, cancellable) virtual¶
- Parameters:
count (
int
) – the number of bytes that will be read from the streamcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore
- Returns:
the number of bytes read into stream's buffer, up to count, or -1 on error.
- Return type:
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
GObject.G_MAXSSIZE
will cause aGio.IOErrorEnum.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 errorGio.IOErrorEnum.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
().
- do_fill_async(count, io_priority, cancellable, callback, *user_data) virtual¶
- Parameters:
count (
int
) – the number of bytes that will be read from the streamio_priority (
int
) – the I/O priority of the requestcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
objectcallback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
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 count is -1 then the attempted read size is equal to the number of bytes that are required to fill the buffer.
- do_fill_finish(result) virtual¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
- Returns:
a #gssize of the read stream, or
-1
on an error.- Return type:
Finishes an asynchronous read.