1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-29 16:08:29 +02:00

Fix return value of PHYSFS_fileLength() being stored in a smaller size

The function returns a PHYSFS_sint64, but we forcefully shove it into a
PHYSFS_uint32. This means we throw away all the negative numbers, which
is bad because the function returns -1 if the size of the file can't be
determined; plus, we also throw away 32 bits of information, reducing
our range of supported file sizes from 9 exabytes to 4 gigabytes.

File size support is only as good as the weakeast link, and it looks
like one of the consumers of FILESYSTEM_loadFileToMemory(),
SDL_RWFromConstMem(), only takes in a signed 32-bit integer of size;
however, I would still like to do at least the bare minimum to support
as many file sizes as we can, and changing types around is one of those
bare minimums.
This commit is contained in:
Misa 2021-03-04 14:30:00 -08:00 committed by Ethan Lee
parent 88b3390e7d
commit 888844cd3a

View File

@ -360,7 +360,7 @@ void FILESYSTEM_loadFileToMemory(
{
return;
}
PHYSFS_uint32 length = PHYSFS_fileLength(handle);
PHYSFS_sint64 length = PHYSFS_fileLength(handle);
if (len != NULL)
{
*len = length;