1 /****************************************************************************** 2 / 3 / File: BufferIO.h 4 / 5 / Description: A buffered adapter for BPositionIO 6 / 7 / Copyright 1998, Be Incorporated 8 / 9 ******************************************************************************/ 10 11 #if !defined(_BUFFER_IO_H) 12 #define _BUFFER_IO_H 13 14 #include <DataIO.h> 15 16 class BBufferIO : public BPositionIO 17 { 18 public: 19 enum { 20 DEFAULT_BUF_SIZE = 65536L 21 }; 22 23 BBufferIO( 24 BPositionIO * stream, 25 size_t buf_size = DEFAULT_BUF_SIZE, 26 bool owns_stream = true); 27 virtual ~BBufferIO(); 28 29 virtual ssize_t ReadAt( 30 off_t pos, 31 void *buffer, 32 size_t size); 33 virtual ssize_t WriteAt( 34 off_t pos, 35 const void *buffer, 36 size_t size); 37 virtual off_t Seek( 38 off_t position, 39 uint32 seek_mode); 40 virtual off_t Position() const; 41 virtual status_t SetSize( 42 off_t size); 43 virtual status_t Flush(); 44 BPositionIO * Stream() const; 45 size_t BufferSize() const; 46 bool OwnsStream() const; 47 void SetOwnsStream( 48 bool owns_stream); 49 50 void PrintToStream() const; 51 52 private: 53 54 off_t m_buffer_start; 55 BPositionIO * m_stream; 56 char * m_buffer; 57 size_t m_buffer_phys; 58 size_t m_buffer_used; 59 uint32 _reserved_ints[6]; 60 bool m_buffer_dirty; 61 bool m_owns_stream; 62 bool _reserved_bools[6]; 63 64 virtual status_t _Reserved_BufferIO_0(void *); 65 virtual status_t _Reserved_BufferIO_1(void *); 66 virtual status_t _Reserved_BufferIO_2(void *); 67 virtual status_t _Reserved_BufferIO_3(void *); 68 virtual status_t _Reserved_BufferIO_4(void *); 69 70 }; 71 72 73 #endif /* _BUFFER_IO_H */ 74