haiku/headers/os/support/BufferIO.h
Axel Dörfler 1b21be7091 * BBufferIO did not implement Seek() and Position() correctly; it just passed
it to the stream. This caused Read()/Write() to need two syscalls for nothing
  (this only caused the actual stream to share the same position with the
  BBufferIO, something you just cannot rely on when using buffered I/O).
* Anyway, this reduces the time VirtualBox needs to open some RAW test images
  from over 4 minutes to less than 15 seconds...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28662 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-11-16 21:23:45 +00:00

51 lines
1.3 KiB
C++

/*
* Copyright 2007-2008, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _BUFFER_IO_H
#define _BUFFER_IO_H
#include <DataIO.h>
class BBufferIO : public BPositionIO {
public:
BBufferIO(BPositionIO* stream, size_t bufferSize = 65536L,
bool ownsStream = true);
virtual ~BBufferIO();
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;
size_t BufferSize() const;
bool OwnsStream() const;
void SetOwnsStream(bool ownsStream);
void PrintToStream() const;
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;
off_t fPosition;
uint32 _reserved_ints[4];
bool fBufferIsDirty;
bool fOwnsStream;
bool _reserved_bools[6];
};
#endif // _BUFFER_IO_H