|
| BBufferIO (BPositionIO *stream, size_t bufferSize=65536L, bool ownsStream=true) |
| Initialize a BBufferIO object.
|
|
virtual | ~BBufferIO () |
| Free the resources allocated by the object.
|
|
size_t | BufferSize () const |
| Return the size of the internal buffer.
|
|
virtual status_t | Flush () |
| Write pending modifications to the stream.
|
|
bool | OwnsStream () const |
| Return whether or not the BBufferIO object "owns" the stream.
|
|
virtual off_t | Position () const |
| Return the current position in the stream.
|
|
void | PrintToStream () const |
| Print the object to standard output.
|
|
virtual ssize_t | ReadAt (off_t pos, void *buffer, size_t size) |
| Read the specified amount of bytes at the given position.
|
|
virtual off_t | Seek (off_t position, uint32 seekMode) |
| Set the position in the stream.
|
|
void | SetOwnsStream (bool ownsStream) |
| Set the owns_stream property of the object.
|
|
virtual status_t | SetSize (off_t size) |
| Call the SetSize() function of the assigned BPositionIO stream.
|
|
BPositionIO * | Stream () const |
| Return a pointer to the stream specified on construction.
|
|
virtual ssize_t | WriteAt (off_t pos, const void *buffer, size_t size) |
| Write the specified amount of bytes at the given position.
|
|
| BPositionIO () |
| This constructor does nothing.
|
|
virtual | ~BPositionIO () |
| This destructor does nothing.
|
|
virtual status_t | GetSize (off_t *size) const |
| Get the size of the object or data.
|
|
virtual off_t | Position () const =0 |
| Pure virtual to return the current position of the cursor.
|
|
virtual ssize_t | Read (void *buffer, size_t size) |
| Read data from current position.
|
|
virtual ssize_t | ReadAt (off_t position, void *buffer, size_t size)=0 |
| Pure virtual to read data from a certain position.
|
|
status_t | ReadAtExactly (off_t position, void *buffer, size_t size, size_t *_bytesRead=NULL) |
| Reads an exact amount of data from the object at the specified position into a buffer.
|
|
virtual off_t | Seek (off_t position, uint32 seekMode)=0 |
| Pure virtual to move the cursor to a certain position.
|
|
virtual status_t | SetSize (off_t size) |
| Set the size of the object or data.
|
|
virtual ssize_t | Write (const void *buffer, size_t size) |
| Write data to the current position.
|
|
virtual ssize_t | WriteAt (off_t position, const void *buffer, size_t size)=0 |
| Pure virtual to write data to a certain position.
|
|
status_t | WriteAtExactly (off_t position, const void *buffer, size_t size, size_t *_bytesWritten=NULL) |
| Writes an exact amount of data from a buffer to the object at the specified position.
|
|
| BDataIO () |
| This constructor does nothing.
|
|
virtual | ~BDataIO () |
| This destructor does nothing.
|
|
virtual status_t | Flush () |
| Writes pending data to underlying storage.
|
|
virtual ssize_t | Read (void *buffer, size_t size) |
| Reads data from the object into a buffer.
|
|
status_t | ReadExactly (void *buffer, size_t size, size_t *_bytesRead=NULL) |
| Reads an exact amount of data from the object into a buffer.
|
|
virtual ssize_t | Write (const void *buffer, size_t size) |
| Writes data from a buffer to the object.
|
|
status_t | WriteExactly (const void *buffer, size_t size, size_t *_bytesWritten=NULL) |
| Writes an exact amount of data from a buffer to the object.
|
|
A buffered adapter for BPositionIO objects.
This class differs from other classes derived from BPositionIO in a sense that it does not actually provide an actual entity to be read or written to, but rather acts like a "frontend" to a stream. This class especially comes in handy when working with files that are constantly written and rewritten and where you want do this writing buffered so that the hard disk or the network will not have to be accessed so frequently.
This class works as follows. After constructing a BBufferIO object that you want to be buffered, you can create this object. The constructor takes a stream parameter that points to the object to be buffered.
You then use this object as a proxy to the resource you want to read of or write to. As soon as you use ReadAt(), the buffer will be initialized to the contents of the original stream, and subsequent calls to the positions within the buffer will not be routed to the original stream. In the same way WriteAt() will change the data in the buffer, but not in the actual stream. In order to flush the changes to the original stream, use the Flush() method. Deleting the object when you are done with it will also flush the stream and update the original stream.
- Note
- This class is not meant to be used in cases where the original stream requires to be in a consistent state. Neither should this class be used as a way to perform 'atomic' writes, because the object might need to do partial writes if it needs to 'move' the buffer. This happens for instance if the original stream is bigger than the buffer.
- Since
- Haiku R1