use HaikuR1::DataIO; # define MyDataIO subclass here my $reader = MyDataIO->new(); my $chunk = $reader->Read($length); my $writer = MyDataIO->new(); my $length_written = $writer->Write($chunk);
from HaikuR1.SupportKit import DataIO # define MyDataIO subclass here reader = MyDataIO() chunk = reader.Read(length) writer = MyDataIO() length_written = writer.Write(chunk)
As a convenience, you can substitute a native IO object or a native string in place of a DataIO; internally it will be wrapped in a suitable C++ object.
Since this internal C++ wrapper derives from
BPositionIO, the guidelines for
native substitutions are found under
Creates a DataIO object.
Flushes any temporary buffer; signals an error if it cannot. The default version does nothing.
May also be called as a hook.
Reads the given number of bytes from the source. Returns the string of bytes.
The default version signals the error
signals an error if it is unable to read the given length, whereas
read fewer bytes.
The returned string may contain null bytes.
Read may also be called as a hook you pass an instance of a subclass to a
method (for example, Flattenable.Unflatten).
ReadExactly is internally implemented using
ReadExactly will result in
Read being called as a hook.
An integer, the number of bytes to read.
Writes the given string of raw bytes from the destination. Returns the number
of bytes written. The default version signals the error
WriteExactly signals an error if it is unable to write the entire string,
Write may write fewer bytes.
Write may also be called as a hook you pass an instance of a subclass to a
method (for example, Flattenable.Flatten).
WriteExactly is internally implemented using
WriteExactly will result in
Write being called as a hook.
A string of bytes to write; may contain null bytes.