|
@@ -70,7 +70,7 @@ void FileStream::skip(size_t bytes)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
|
-uint8_t FileStream::read_byte()
|
|
|
|
|
|
|
+void FileStream::read(void* buffer, size_t size)
|
|
|
{
|
|
{
|
|
|
check_valid();
|
|
check_valid();
|
|
|
|
|
|
|
@@ -80,25 +80,21 @@ uint8_t FileStream::read_byte()
|
|
|
m_file.seek(0);
|
|
m_file.seek(0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- uint8_t buffer;
|
|
|
|
|
-
|
|
|
|
|
- ce_assert(m_file.read(&buffer, 1) == 1, "Failed to read from file");
|
|
|
|
|
-
|
|
|
|
|
- return buffer;
|
|
|
|
|
|
|
+ ce_assert(m_file.read(buffer, size) == size, "Failed to read from file");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
|
-void FileStream::read(void* buffer, size_t size)
|
|
|
|
|
|
|
+void FileStream::write(const void* buffer, size_t size)
|
|
|
{
|
|
{
|
|
|
check_valid();
|
|
check_valid();
|
|
|
|
|
|
|
|
- if (!m_last_was_read)
|
|
|
|
|
|
|
+ if (m_last_was_read)
|
|
|
{
|
|
{
|
|
|
- m_last_was_read = true;
|
|
|
|
|
|
|
+ m_last_was_read = false;
|
|
|
m_file.seek(0);
|
|
m_file.seek(0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ce_assert(m_file.read(buffer, size) == size, "Failed to read from file");
|
|
|
|
|
|
|
+ ce_assert(m_file.write(buffer, size) == size, "Failed to write to file");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
@@ -154,34 +150,6 @@ bool FileStream::is_valid() const
|
|
|
return m_file.is_open();
|
|
return m_file.is_open();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//-----------------------------------------------------------------------------
|
|
|
|
|
-void FileStream::write_byte(uint8_t val)
|
|
|
|
|
-{
|
|
|
|
|
- check_valid();
|
|
|
|
|
-
|
|
|
|
|
- if (m_last_was_read)
|
|
|
|
|
- {
|
|
|
|
|
- m_last_was_read = false;
|
|
|
|
|
- m_file.seek(0);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- ce_assert(m_file.write(&val, 1) == 1, "Failed to write to file");
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-//-----------------------------------------------------------------------------
|
|
|
|
|
-void FileStream::write(const void* buffer, size_t size)
|
|
|
|
|
-{
|
|
|
|
|
- check_valid();
|
|
|
|
|
-
|
|
|
|
|
- if (m_last_was_read)
|
|
|
|
|
- {
|
|
|
|
|
- m_last_was_read = false;
|
|
|
|
|
- m_file.seek(0);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- ce_assert(m_file.write(buffer, size) == size, "Failed to write to file");
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
|
void FileStream::flush()
|
|
void FileStream::flush()
|
|
|
{
|
|
{
|