Hi,
In src/hostfs.c there are two occurrences of 'ftell' which is limited by
being prototyped as a long. On WinXP (and no doubt others) this returns -1
and sets errno to EOVERFLOW if the filesize can't be represented as a signed
long. Therefore files > 2G always falsely report a length of 4G-1.
The following patch changes to use ftello64, and for fseek to use fseeko64.
This makes files return the correct extent when opened through FileSwitch.
Cheers,
Sprow.
--- RPCEmu.hostfs/c 2011-10-16 11:44:35.0 +0100
+++ RPCEmu.rpcemu-0/8/6.src.hostfs/c 2011-10-16 11:44:35.0 +0100
@@ -786,8 +786,8 @@
}
/* Find the extent of the file */
- fseek(open_file[idx], 0L, SEEK_END);
- state->Reg[3] = ftell(open_file[idx]);
+ fseeko64(open_file[idx], 0uLL, SEEK_END);
+ state->Reg[3] = (ARMword) ftello64(open_file[idx]);
rewind(open_file[idx]); /* Return to start */
state->Reg[1] = idx; /* Our filing system's handle */
@@ -814,7 +814,7 @@
hostfs_ensure_buffer_size(state->Reg[3]);
- fseek(f, (long) state->Reg[4], SEEK_SET);
+ fseeko64(f, (off64_t) state->Reg[4], SEEK_SET);
fread(buffer, 1, state->Reg[3], f);
@@ -841,7 +841,7 @@
hostfs_ensure_buffer_size(state->Reg[3]);
- fseek(f, (long) state->Reg[4], SEEK_SET);
+ fseeko64(f, (off64_t) state->Reg[4], SEEK_SET);
for (i = 0; i < state->Reg[3]; i++) {
buffer[i] = (unsigned char)ARMul_LoadByte(state, ptr);
@@ -902,9 +902,9 @@
dbug_hostfs("\tr1 = %u (our file handle)\n", state->Reg[1]);
dbug_hostfs("\tr2 = %u (size of file to ensure)\n", state->Reg[2]);
- fseek(f, 0L, SEEK_END);
+ fseeko64(f, 0uLL, SEEK_END);
- state->Reg[2] = (ARMword) ftell(f);
+ state->Reg[2] = (ARMword) ftello64(f);
}
static void
_______________________________________________
Rpcemu mailing list
[email protected]
http://www.riscos.info/cgi-bin/mailman/listinfo/rpcemu