1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/lib/Filesystem/CMemoryStream.cpp
Ivan Savenko e67f8afdd9 - removed multiple unused files
- config folder with all json files is used via new FS API
- fixed campaigns loading. Replaced "detect h3m starts" heuristics with CCompessedStream::getNextBlock()
2012-08-02 11:03:26 +00:00

49 lines
756 B
C++

#include "StdInc.h"
#include "CMemoryStream.h"
CMemoryStream::CMemoryStream(const ui8 * data, si64 size, bool freeData /*= false*/):
data(data),
size(size),
position(0),
freeData(freeData)
{
}
CMemoryStream::~CMemoryStream()
{
if(freeData)
{
delete[] data;
}
}
si64 CMemoryStream::read(ui8 * data, si64 size)
{
std::copy(this->data + position, this->data + position + size, data);
position += size;
return size;
}
si64 CMemoryStream::seek(si64 position)
{
si64 diff = this->position;
this->position = position;
return position - diff;
}
si64 CMemoryStream::tell()
{
return this->position;
}
si64 CMemoryStream::skip(si64 delta)
{
this->position += delta;
return delta;
}
si64 CMemoryStream::getSize()
{
return size;
}