void PLDataSource::Seek ( int n ) { m_BytesRead = n; CheckEOF(); }
String* DataInput::ReadUTFBytes(uint32_t length) { CheckEOF(length); char *buffer = mmfx_new_array_opt( char, length+1, MMgc::kCanFail ); if (!buffer) { ThrowMemoryError(); } Read(buffer, length); buffer[length] = 0; // Since this is supposed to read UTF8 into a string, it really should ignore the UTF8 BOM that // might reasonably occur at the head of the data. char* utf8chars = buffer; if (length >= 3 && (unsigned char)buffer[0] == 0xEF && (unsigned char)buffer[1] == 0xBB && (unsigned char)buffer[2] == 0xBF) { utf8chars += 3; } String *out = m_toplevel->core()->newStringUTF8(utf8chars); mmfx_delete_array( buffer ); return out; }
void ByteArrayFile::Read(void *buffer, uint32_t count) { CheckEOF(count); if (count > 0) { VMPI_memcpy(buffer, m_array+m_filePointer, count); m_filePointer += count; } }
PLBYTE * PLDataSource::ReadNBytes ( int n ) { int OldBytesRead = m_BytesRead; m_BytesRead += n; if (m_BytesRead/1024 > OldBytesRead/1024 && m_pNotification) m_pNotification->OnProgress (double(m_BytesRead)/m_FileSize); CheckEOF(); return NULL; }
void SocketFile::ReadOutCache(void *data, uint32_t length) { CheckEOF(length); if (length > 0) { VMPI_memcpy(data, m_outCache.GetBuffer() + m_outReadPos, length); m_outReadPos += length; } //if (0 == OutCacheBytesAvailable()) //{ // m_outReadPos = m_outWritePos = 0; //} }
void SocketFile::ReadInCache(void *data, uint32_t count) { CheckEOF(count); if (count > 0) { AvmAssert(m_inReadPos+count<=m_inCache.GetLength()); VMPI_memcpy(data, m_inCache.GetBuffer() + m_inReadPos, count); m_inReadPos += count; } //if (0 == InCacheBytesAvailable()) //{ // m_inReadPos = m_inWritePos = 0; //} }