gio.BufferedInputStream Buffered Input Stream Synopsis gio.BufferedInputStream gio.FilterInputStream gio.BufferedInputStream base_stream fill count cancellableNone fill_async count callback io_priorityglib.PRIORITY_DEFAULT cancellableNone user_dataNone fill_finish result get_available get_buffer_size read_byte cancellableNone set_buffer_size size Functions gio.buffered_input_stream_new_sized size Ancestry +-- gobject.GObject +-- gio.InputStream +-- gio.FilterInputStream +-- gio.BufferedInputStream gio.BufferedInputStream Properties
"buffer-size" Read - Write - Construct The size of the backend buffer. Allowed values: >= 1. Default value: 4096.
Description 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. Constructor gio.BufferedInputStream base_stream 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). Methods gio.BufferedInputStream.fill fill count cancellableNone 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 fill_async count callback io_priorityglib.PRIORITY_DEFAULT cancellableNone user_dataNone 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 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 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 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 get_buffer_size Returns : the current buffer size. The get_buffer_size() method gets the size of the input buffer. gio.BufferedInputStream.read_byte read_byte cancellableNone 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 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. Functions gio.buffered_input_stream_new_sized buffered_input_stream_new_sized size 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.