mirror of
https://github.com/libAthena/athena.git
synced 2025-12-09 21:47:52 +00:00
lots of new streaming interface additions
This commit is contained in:
@@ -185,6 +185,14 @@ atUint8* FileReader::readUBytes(atUint64 len)
|
||||
fread(val, 1, len, m_fileHandle);
|
||||
return val;
|
||||
}
|
||||
|
||||
atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
m_bitValid = false;
|
||||
return fread(buf, 1, len, m_fileHandle);
|
||||
}
|
||||
|
||||
atInt8* FileReader::readBytes(atUint64 len)
|
||||
{
|
||||
|
||||
@@ -224,11 +224,6 @@ atUint8 MemoryReader::readUByte()
|
||||
return *(atUint8*)(m_data + m_position++);
|
||||
}
|
||||
|
||||
atInt8* MemoryReader::readBytes(atUint64 length)
|
||||
{
|
||||
return (atInt8*)readUBytes(length);
|
||||
}
|
||||
|
||||
atUint8* MemoryReader::readUBytes(atUint64 length)
|
||||
{
|
||||
if (!m_data)
|
||||
@@ -250,7 +245,26 @@ atUint8* MemoryReader::readUBytes(atUint64 length)
|
||||
m_position += length;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
atUint64 MemoryReader::readUBytesToBuf(void* buf, atUint64 length)
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(atUint8);
|
||||
}
|
||||
|
||||
if (m_position + length > m_length)
|
||||
THROW_IO_EXCEPTION("Position %0.16X outside stream bounds ", m_position);
|
||||
|
||||
memcpy(buf, (const atUint8*)(m_data + m_position), length);
|
||||
m_position += length;
|
||||
return length;
|
||||
}
|
||||
|
||||
atInt16 MemoryReader::readInt16()
|
||||
{
|
||||
if (!m_data)
|
||||
|
||||
Reference in New Issue
Block a user