BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / translators / shared / StreamBuffer.h
blob4f19c12e777a33c4ba065aa2e50f3cac754d2e4d
1 /*
2 * Copyright 2003-2008, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors :
6 * Michael Wilber
7 * Jérôme Duval
8 */
10 #ifndef STREAM_BUFFER_H
11 #define STREAM_BUFFER_H
13 #include <DataIO.h>
15 #define MIN_BUFFER_SIZE 512
17 class StreamBuffer {
18 public:
19 StreamBuffer(BPositionIO *stream, size_t bufferSize, bool toRead = true);
20 ~StreamBuffer();
22 status_t InitCheck();
23 // Determines whether the constructor failed or not
25 ssize_t Read(void *buffer, size_t size);
26 // copy nbytes from the stream into pinto
28 void Write(void *buffer, size_t size);
29 // copy nbytes from the stream into pinto
31 off_t Seek(off_t position, uint32 seekMode);
32 // seek the stream to the given position
34 off_t Position();
35 // return the actual position
36 private:
37 ssize_t _ReadStream();
38 // Load the stream buffer from the stream
40 BPositionIO *fStream;
41 // stream object this object is buffering
42 uint8 *fBuffer;
43 // buffered data from fpStream
44 size_t fBufferSize;
45 // number of bytes of memory allocated for fpBuffer
46 size_t fLen;
47 // number of bytes of actual data in fpBuffer
48 size_t fPos;
49 // current position in the buffer
50 bool fToRead;
51 // whether the stream is to be read.
54 #endif