size_t hsRAMStream::read(size_t size, void* buf) { if (size + fPos > fSize) throw hsFileReadException(__FILE__, __LINE__, "Read past end of buffer"); memcpy(buf, fData + fPos, size); fPos += size; return size; }
size_t pfSizedStream::write(size_t size, const void* buf) { if (pos() + size > fLength) { // pos() is the index in the sub-stream throw hsFileReadException(__FILE__, __LINE__, plString::Format("Write past end of sized stream: %d bytes requested, %d available", size, (fLength - pos()))); } return fBase->write(size, buf); }
void pfSizedStream::skip(int32_t count) { if (pos() + count > fLength) { // pos() is the index in the sub-stream throw hsFileReadException(__FILE__, __LINE__, plString::Format("Seek out of range: %d bytes requested, %d available", count, (fLength - pos()))); } fBase->skip(count); }
size_t pfSizedStream::read(size_t size, void* buf) { if (pos() + size > fLength) { // pos() is the index in the sub-stream throw hsFileReadException(__FILE__, __LINE__, ST::format("Read past end of sized stream: {} bytes requested, {} available", size, (fLength - pos())).c_str()); } return fBase->read(size, buf); }