BufferedInputStream

Buffered input stream 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 BufferedInputStream.new, or BufferedInputStream.newSized to specify the buffer's size at construction.

To get the size of a buffer within a buffered input stream, use BufferedInputStream.getBufferSize. To change the size of a buffered input stream's buffer, use BufferedInputStream.setBufferSize. Note that the buffer's size cannot be reduced below the size of the data within the buffer.

Constructors

this
this(GBufferedInputStream* gBufferedInputStream, bool ownedRef = false)

Sets our main struct and passes it to the parent class.

this
this(InputStream baseStream)

Creates a new gio.InputStream from the given base_stream, with a buffer set to the default size (4 kilobytes).

this
this(InputStream baseStream, size_t size)

Creates a new gio.BufferedInputStream from the given base_stream, with a buffer set to size.

Members

Functions

fill
ptrdiff_t fill(ptrdiff_t count, Cancellable cancellable)

Tries to read count bytes from the stream into the buffer. Will block during this read.

fillAsync
void fillAsync(ptrdiff_t count, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

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 BufferedInputStream.fill.

fillFinish
ptrdiff_t fillFinish(AsyncResultIF result)

Finishes an asynchronous read.

getAvailable
size_t getAvailable()

Gets the size of the available data within the stream.

getBufferSize
size_t getBufferSize()

Gets the size of the input buffer.

getBufferedInputStreamStruct
GBufferedInputStream* getBufferedInputStreamStruct(bool transferOwnership = false)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

peek
size_t peek(ubyte[] buffer, size_t offset)

Peeks in the buffer, copying data of size count into buffer, offset offset bytes.

peekBuffer
ubyte[] peekBuffer()

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.

readByte
int readByte(Cancellable cancellable)

Tries to read a single byte from the stream or the buffer. Will block during this read.

setBufferSize
void setBufferSize(size_t size)

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.

Static functions

getType
GType getType()

Variables

gBufferedInputStream
GBufferedInputStream* gBufferedInputStream;

the main Gtk struct

Inherited Members

From FilterInputStream

gFilterInputStream
GFilterInputStream* gFilterInputStream;

the main Gtk struct

getFilterInputStreamStruct
GFilterInputStream* getFilterInputStreamStruct(bool transferOwnership = false)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getType
GType getType()
getBaseStream
InputStream getBaseStream()

Gets the base stream for the filter stream.

getCloseBaseStream
bool getCloseBaseStream()

Returns whether the base stream will be closed when stream is closed.

setCloseBaseStream
void setCloseBaseStream(bool closeBase)

Sets whether the base stream will be closed when stream is closed.

From SeekableIF

getSeekableStruct
GSeekable* getSeekableStruct(bool transferOwnership = false)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getType
GType getType()
canSeek
bool canSeek()

Tests if the stream supports the GSeekableIface

canTruncate
bool canTruncate()

Tests if the length of the stream can be adjusted with g_seekable_truncate().

seek
bool seek(long offset, GSeekType type, Cancellable cancellable)

Seeks in the stream by the given offset, modified by type.

tell
long tell()

Tells the current position within the stream.

truncate
bool truncate(long offset, Cancellable cancellable)

Sets the length of the stream to offset. If the stream was previously larger than offset, the extra data is discarded. If the stream was previouly shorter than offset, it is extended with NUL ('\0') bytes.

Meta