| Class Overview |
BPositionIO();
Does nothing. Constructors in derived classes should initialize the object to default values—for example, set the current position to the beginning of the data.
virtual ssize_t Read(void* buffer,
size_t numBytes);
virtual ssize_t ReadAt(off_t position,
void* buffer,
size_t numBytes) = 0;
Read()
copies numBytes
bytes
of data from the object to the buffer
. It
returns the number of bytes actually read (which may be 0) or an error
code if something goes wrong. Read()
is implemented using
Seek()
,
ReadAt()
,
and Position()
,
all of which are pure virtual functions.
ReadAt()
is a pure virtual that must be implemented by derived classes to
read numBytes
bytes of data beginning at position
in the data source, and
to place them in the buffer
. It should return the number of bytes
actually read, or an error code if something goes wrong.
virtual off_t Seek(off_t position,
int32 mode) = 0;
virtual off_t Position() const = 0;
Seek()
is implemented by derived classes to modify the current position
maintained by the object. The current position is an offset in bytes from
the beginning of the object's data. How the position
argument is
interpreted will depend on the mode
flag. Three possible modes should be
supported:
Constant | Description |
---|---|
| The |
| The |
| The |
For the SEEK_SET
mode, position
should be a positive value. The other
modes permit negative offsets.
Seek()
should return the new position.
Position()
should return the current position.
virtual status_t SetSize(off_t numBytes);
Returns B_ERROR
to indicate that, in general,
BPositionIO
objects can't
set the amount of memory in the repositories they represent. However, the
BMallocIO
class in this kit and
BFile
in the
Storage Kit implement
SetSize()
functions that override this default.
virtual ssize_t Write(const void* buffer,
size_t numBytes);
virtual ssize_t WriteAt(off_t position,
const void* buffer,
size_t numBytes) = 0;
Write()
copies numBytes
bytes of data from the object into the buffer
. It
returns the number of bytes actually written (which may be 0) or an error
code if something goes wrong. Write()
is implemented using
Seek()
,
Position()
,
and WriteAt()
, all of which are pure virtual functions.
WriteAt()
is a pure virtual that must be implemented by derived classes
to copy numBytes
bytes of data from buffer
and write them into the
object, starting at byte position
within the object. It should return the
number of bytes actually read, or an error code if something goes wrong.