Class: Gio::BufferedInputStream
- Inherits:
-
FilterInputStream
- Object
- InputStream
- FilterInputStream
- Gio::BufferedInputStream
- Defined in:
- (unknown)
Direct Known Subclasses
Instance Method Summary collapse
-
#available ⇒ Integer
Gets the size of the available data within the stream.
-
#buffer_size ⇒ Integer
The size of the backend buffer, in bytes.
-
#buffer_size=(buffer_size) ⇒ Integer
The size of the backend buffer, in bytes.
-
#fill(count, cancellable) ⇒ Gio::gssize
Tries to read count bytes from the stream into the buffer.
-
#fill_async(count, io_priority, cancellable, callback, user_data) ⇒ nil
Reads data into stream's buffer asynchronously, up to count size.
-
#fill_finish(result) ⇒ Gio::gssize
Finishes an asynchronous read.
-
#initialize(base_stream, size) ⇒ Gio::InputStream
constructor
Creates a new [classGio.BufferedInputStream] from the given base_stream, with a buffer set to size.
-
#peek(buffer, offset, count) ⇒ Integer
Peeks in the buffered input, copying count bytes of data from offset bytes in the buffered input into buffer.
-
#peek_buffer(count) ⇒ Array<Integer>
Returns the buffer with the currently available bytes.
-
#read_byte(cancellable) ⇒ Integer
Tries to read a single byte from the stream or the buffer.
Methods inherited from FilterInputStream
#base_stream, #base_stream=, #close_base_stream, #close_base_stream=, #close_base_stream?
Methods inherited from InputStream
#clear_pending, #close, #close_async, #close_finish, #has_pending, #is_closed, open, #read, #read_all, #read_all_async, #read_all_finish, #read_all_raw, #read_async, #read_bytes, #read_bytes_async, #read_bytes_finish, #read_finish, #read_raw, #set_pending, #skip, #skip_async, #skip_finish
Constructor Details
#initialize(base_stream, size) ⇒ Gio::InputStream
Creates a new [classGio.BufferedInputStream] from the given base_stream,
with a buffer set to size.
Instance Method Details
#available ⇒ Integer
Gets the size of the available data within the stream.
#buffer_size ⇒ Integer
The size of the backend buffer, in bytes.
#buffer_size=(buffer_size) ⇒ Integer
The size of the backend buffer, in bytes.
#fill(count, cancellable) ⇒ Gio::gssize
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
[errorGio.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 NULL, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error [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
[methodGio.BufferedInputStream.fill_async].
#fill_async(count, io_priority, cancellable, callback, user_data) ⇒ nil
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 [methodGio.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) ⇒ Gio::gssize
Finishes an asynchronous read.
#peek(buffer, offset, count) ⇒ Integer
Peeks in the buffered input, copying count bytes of data from offset bytes
in the buffered input into buffer.
#peek_buffer(count) ⇒ Array<Integer>
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) ⇒ Integer
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 NULL, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error [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.