Added BDebugEventInputStream::Seek() to seek in the stream. Works for data

buffer based stream only ATM.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31855 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2009-07-28 18:51:38 +00:00
parent 5c7514c317
commit 86e89f1207
2 changed files with 21 additions and 1 deletions

View File

@ -44,6 +44,8 @@ public:
bool takeOverOwnership);
void Unset();
status_t Seek(off_t streamOffset);
ssize_t ReadNextEvent(uint32* _event, uint32* _cpu,
const void** _buffer,
off_t* _streamOffset = NULL);

View File

@ -116,6 +116,24 @@ BDebugEventInputStream::Unset()
}
status_t
BDebugEventInputStream::Seek(off_t streamOffset)
{
// TODO: Support for streams, at least for BPositionIOs.
if (fStream != NULL)
return B_UNSUPPORTED;
if (streamOffset < 0 || streamOffset > fBufferCapacity)
return B_BUFFER_OVERFLOW;
fStreamPosition = 0;
fBufferPosition = streamOffset;
fBufferSize = fBufferCapacity - streamOffset;
return B_OK;
}
/*! \brief Returns the next event in the stream.
At the end of the stream \c 0 is returned and \c *_buffer is set to \c NULL.
@ -254,7 +272,7 @@ BDebugEventInputStream::_GetData(size_t size)
fBufferCapacity - fBufferSize);
if (bytesRead < 0)
return bytesRead;
fBufferSize += bytesRead;
}