EXRTranslator now uses the StreamBuffer class

added StreamBuffer::Position()


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24069 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2008-02-22 22:00:41 +00:00
parent e26a124818
commit 45ff9decad
4 changed files with 36 additions and 5 deletions

View File

@ -8,7 +8,7 @@
IStreamWrapper::IStreamWrapper(const char *filename, BPositionIO *stream)
: IStream(filename),
fStream(stream)
fStream(stream, 2048)
{
}
@ -21,7 +21,7 @@ IStreamWrapper::~IStreamWrapper()
bool
IStreamWrapper::read(char c[/*n*/], int n)
{
int actual = fStream->Read(c, n);
int actual = fStream.Read(c, n);
if (actual < B_OK) {
}
@ -32,12 +32,12 @@ IStreamWrapper::read(char c[/*n*/], int n)
Int64
IStreamWrapper::tellg()
{
return fStream->Position();
return fStream.Position();
}
void
IStreamWrapper::seekg(Int64 pos)
{
fStream->Seek(pos, SEEK_SET);
fStream.Seek(pos);
}

View File

@ -8,6 +8,8 @@
#include <DataIO.h>
#include <ImfIO.h>
#include "StreamBuffer.h"
using namespace Imf;
class IStreamWrapper : public IStream {
@ -20,7 +22,7 @@ class IStreamWrapper : public IStream {
virtual void seekg(Int64 pos);
private:
BPositionIO *fStream;
StreamBuffer fStream;
};
#endif /* ISTREAM_WRAPPER_H */

View File

@ -202,6 +202,33 @@ StreamBuffer::Seek(off_t position)
return false;
}
// ---------------------------------------------------------------
// Position
//
// Returns the current position in the stream.
//
// Preconditions: fBuffer must be allocated and fBufferSize
// must be valid
//
// Parameters:
//
// Postconditions:
//
// Returns: the position
// ---------------------------------------------------------------
off_t
StreamBuffer::Position()
{
off_t position = fStream->Position();
if (fToRead)
position -= fPos;
else
position += fLen;
return position;
}
// ---------------------------------------------------------------
// _ReadStream
//

View File

@ -31,6 +31,8 @@ public:
bool Seek(off_t position);
// seek the stream to the given position
off_t Position();
// return the actual position
private:
ssize_t _ReadStream();
// Load the stream buffer from the stream