irrlicht/source/Irrlicht/tests/inMemoryFile.cpp
JosiahWI df5a413083
Test invalid JSON
Also converted all .cpp and .h line endings to CRLF in this commit.
2023-01-27 16:17:13 -06:00

55 lines
900 B
C++

#include "inMemoryFile.h"
#include <irrlicht.h>
#include <ios>
namespace irr
{
namespace io
{
InMemoryFile::InMemoryFile(const io::path& filename, const std::string& s)
: m_filename { filename }
, m_sstream { s }
{
}
std::size_t InMemoryFile::read(void* buffer, std::size_t sizeToRead)
{
m_sstream.read(reinterpret_cast<char*>(buffer), sizeToRead);
return m_sstream.gcount();
}
bool InMemoryFile::seek(long finalPos, bool relativeMovement)
{
if (relativeMovement) {
m_sstream.seekg(finalPos, std::ios::beg);
} else {
m_sstream.seekg(finalPos);
}
return m_sstream.fail();
}
long InMemoryFile::getSize() const
{
return m_sstream.str().size();
}
long InMemoryFile::getPos() const
{
return m_sstream.tellg();
}
const io::path& InMemoryFile::getFileName() const
{
return m_filename;
}
} // namespace irr
} // namespace io