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:
parent
e26a124818
commit
45ff9decad
@ -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);
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
//
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user