1 /* 2 * Copyright 2007-2008, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _BUFFER_IO_H 6 #define _BUFFER_IO_H 7 8 9 #include <DataIO.h> 10 11 12 class BBufferIO : public BPositionIO { 13 public: 14 BBufferIO(BPositionIO* stream, size_t bufferSize = 65536L, 15 bool ownsStream = true); 16 virtual ~BBufferIO(); 17 18 virtual ssize_t ReadAt(off_t pos, void* buffer, size_t size); 19 virtual ssize_t WriteAt(off_t pos, const void* buffer, size_t size); 20 virtual off_t Seek(off_t position, uint32 seekMode); 21 virtual off_t Position() const; 22 virtual status_t SetSize(off_t size); 23 virtual status_t Flush(); 24 BPositionIO* Stream() const; 25 size_t BufferSize() const; 26 bool OwnsStream() const; 27 void SetOwnsStream(bool ownsStream); 28 29 void PrintToStream() const; 30 31 private: 32 virtual status_t _Reserved_BufferIO_0(void*); 33 virtual status_t _Reserved_BufferIO_1(void*); 34 virtual status_t _Reserved_BufferIO_2(void*); 35 virtual status_t _Reserved_BufferIO_3(void*); 36 virtual status_t _Reserved_BufferIO_4(void*); 37 38 off_t fBufferStart; 39 BPositionIO* fStream; 40 char* fBuffer; 41 size_t fBufferSize; 42 size_t fBufferUsed; 43 off_t fPosition; 44 uint32 _reserved_ints[4]; 45 bool fBufferIsDirty; 46 bool fOwnsStream; 47 bool _reserved_bools[6]; 48 }; 49 50 #endif // _BUFFER_IO_H 51