Added pointer checks to Android's resource stream.

This fixes issues #1056.
This commit is contained in:
Michał Marszałek 2016-02-08 18:09:59 +01:00 committed by Lukas Dürrenberger
parent 61526628d1
commit 36bb3c4531

View File

@ -49,35 +49,66 @@ m_file (NULL)
////////////////////////////////////////////////////////////
ResourceStream::~ResourceStream()
{
if (m_file)
{
AAsset_close(m_file);
}
}
////////////////////////////////////////////////////////////
Int64 ResourceStream::read(void *data, Int64 size)
{
if (m_file)
{
return AAsset_read(m_file, data, size);
}
else
{
return -1;
}
}
////////////////////////////////////////////////////////////
Int64 ResourceStream::seek(Int64 position)
{
if (m_file)
{
return AAsset_seek(m_file, position, SEEK_SET);
}
else
{
return -1;
}
}
////////////////////////////////////////////////////////////
Int64 ResourceStream::tell()
{
if (m_file)
{
return getSize() - AAsset_getRemainingLength(m_file);
}
else
{
return -1;
}
}
////////////////////////////////////////////////////////////
Int64 ResourceStream::getSize()
{
if (m_file)
{
return AAsset_getLength(m_file);
}
else
{
return -1;
}
}