2007-01-26 19:36:29 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2007, Haiku, Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _BUFFER_IO_H
|
2002-10-23 17:54:44 +04:00
|
|
|
#define _BUFFER_IO_H
|
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
|
2002-10-23 17:54:44 +04:00
|
|
|
#include <DataIO.h>
|
|
|
|
|
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
class BBufferIO : public BPositionIO {
|
|
|
|
public:
|
|
|
|
BBufferIO(BPositionIO* stream, size_t bufferSize = 65536L,
|
|
|
|
bool ownsStream = true);
|
|
|
|
virtual ~BBufferIO();
|
2002-10-23 17:54:44 +04:00
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
virtual ssize_t ReadAt(off_t pos, void* buffer, size_t size);
|
|
|
|
virtual ssize_t WriteAt(off_t pos, const void* buffer, size_t size);
|
|
|
|
virtual off_t Seek(off_t position, uint32 seekMode);
|
|
|
|
virtual off_t Position() const;
|
|
|
|
virtual status_t SetSize(off_t size);
|
|
|
|
virtual status_t Flush();
|
|
|
|
BPositionIO* Stream() const;
|
2002-10-23 17:54:44 +04:00
|
|
|
size_t BufferSize() const;
|
|
|
|
bool OwnsStream() const;
|
2007-01-26 19:36:29 +03:00
|
|
|
void SetOwnsStream(bool ownsStream);
|
2002-10-23 17:54:44 +04:00
|
|
|
|
|
|
|
void PrintToStream() const;
|
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
private:
|
|
|
|
virtual status_t _Reserved_BufferIO_0(void*);
|
|
|
|
virtual status_t _Reserved_BufferIO_1(void*);
|
|
|
|
virtual status_t _Reserved_BufferIO_2(void*);
|
|
|
|
virtual status_t _Reserved_BufferIO_3(void*);
|
|
|
|
virtual status_t _Reserved_BufferIO_4(void*);
|
|
|
|
|
|
|
|
off_t fBufferStart;
|
|
|
|
BPositionIO* fStream;
|
|
|
|
char* fBuffer;
|
|
|
|
size_t fBufferSize;
|
|
|
|
size_t fBufferUsed;
|
2002-10-23 17:54:44 +04:00
|
|
|
uint32 _reserved_ints[6];
|
2007-01-26 19:36:29 +03:00
|
|
|
bool fBufferIsDirty;
|
|
|
|
bool fOwnsStream;
|
2002-10-23 17:54:44 +04:00
|
|
|
bool _reserved_bools[6];
|
|
|
|
};
|
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
#endif // _BUFFER_IO_H
|