Support larger iso files (more than 2GB.)

No actual PSP games are this big (a UMD can only go up to 1.8 GB), but it
can be convenient for combined multi-game discs.  Fixes #5169.
This commit is contained in:
Unknown W. Brackets 2014-01-23 22:00:15 -08:00
parent d69f02dea0
commit 6bdfa5a13a
2 changed files with 10 additions and 13 deletions

View File

@ -47,9 +47,9 @@ BlockDevice *constructBlockDevice(const char *filename) {
FileBlockDevice::FileBlockDevice(FILE *file)
: f(file)
{
fseek(f,0,SEEK_END);
filesize = ftell(f);
fseek(f,0,SEEK_SET);
fseek(f, 0, SEEK_END);
filesize = ftello(f);
fseek(f, 0, SEEK_SET);
}
FileBlockDevice::~FileBlockDevice()
@ -59,9 +59,9 @@ FileBlockDevice::~FileBlockDevice()
bool FileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr)
{
fseek(f, blockNumber * GetBlockSize(), SEEK_SET);
if(fread(outPtr, 1, 2048, f) != 2048)
DEBUG_LOG(LOADER, "Could not read 2048 bytes from block");
fseeko(f, (u64)blockNumber * (u64)GetBlockSize(), SEEK_SET);
if (fread(outPtr, 1, 2048, f) != 2048)
DEBUG_LOG(FILESYS, "Could not read 2048 bytes from block");
return true;
}
@ -172,13 +172,10 @@ bool CISOFileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr)
int plain = idx & 0x80000000;
idx = (idx & 0x7FFFFFFF) << indexShift;
idx2 = (idx2 & 0x7FFFFFFF) << indexShift;
u64 compressedReadPos = (u64)(idx & 0x7FFFFFFF) << indexShift;
size_t compressedReadSize = (size_t)(((u64)(idx2 & 0x7FFFFFFF) << indexShift) - compressedReadPos);
u32 compressedReadPos = idx;
u32 compressedReadSize = idx2 - idx;
fseek(f, compressedReadPos, SEEK_SET);
fseeko(f, compressedReadPos, SEEK_SET);
u32 readSize = (u32)fread(inbuffer, 1, compressedReadSize, f);
if (plain)

View File

@ -63,7 +63,7 @@ public:
private:
FILE *f;
size_t filesize;
u64 filesize;
};