mirror of
https://github.com/dborth/fceugx.git
synced 2025-01-05 21:38:17 +01:00
fix bug w/ reading files < 2048 bytes
This commit is contained in:
parent
9ed631add7
commit
31c1d13fcf
@ -440,13 +440,12 @@ LoadFileBuf (char * rbuffer, char *filepath, u32 length, int method, bool silent
|
||||
fstat(file->_file, &fileinfo);
|
||||
size = fileinfo.st_size;
|
||||
|
||||
memcpy (rbuffer, zipbuffer, 2048); // copy what we already read
|
||||
memcpy (rbuffer, zipbuffer, readsize); // copy what we already read
|
||||
|
||||
ShowProgress ("Loading...", 2048, length);
|
||||
|
||||
u32 offset = 2048;
|
||||
u32 offset = readsize;
|
||||
while(offset < size)
|
||||
{
|
||||
ShowProgress ("Loading...", offset, size);
|
||||
readsize = fread (rbuffer + offset, 1, (1024*512), file); // read in 512K chunks
|
||||
|
||||
if(readsize <= 0 || readsize > (1024*512))
|
||||
@ -454,7 +453,6 @@ LoadFileBuf (char * rbuffer, char *filepath, u32 length, int method, bool silent
|
||||
|
||||
if(readsize > 0)
|
||||
offset += readsize;
|
||||
ShowProgress ("Loading...", offset, length);
|
||||
}
|
||||
|
||||
if(offset != size) // # bytes read doesn't match # expected
|
||||
|
@ -807,6 +807,8 @@ ShowProgress (const char *msg, int done, int total)
|
||||
return;
|
||||
else if(done > total) // this shouldn't happen
|
||||
done = total;
|
||||
else if(total < (256*1024)) // don't bother showing progress for small files
|
||||
return;
|
||||
|
||||
int xpos, ypos;
|
||||
int i;
|
||||
|
Loading…
Reference in New Issue
Block a user