-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ftello() issue with big files #112
Comments
@bucanero methinks your printf has the wrong format specifier.
|
Actually, |
hello, thanks for the answers 👍
oh I fixed my printf (now using
from my test above (the ~4 GB file) it seems that somewhere there might be a 32-bit conversion, even if everything is 64 bits. Any ideas where I could look? newlib or somewhere else? |
I'd start by looking at the libsysbase implementation of |
Yeah without setting up and doing some tests and debugging I have no clue where to point you to. |
thanks @zeldin , I'll take a look around |
I was looking around, and by chance I found this old psl1ght example code from Estwald, where he is using // NOTE: for files > 2GB you can use 64 bit method
#ifdef USE_64BIT_SEEK
struct _reent reent1;
DPrintf ("Using _lseek64_r for large files\n");
s64 size = _lseek64_r(&reent1, fp->_file, 0, SEEK_END);
_lseek64_r(&reent1, fp->_file, 0, SEEK_SET);
DPrintf ("Size of file %i bytes\n", (int) size);
#else
fseek(fp, 0, SEEK_END);
int size = ftell(fp);
DPrintf ("Size of file %i bytes\n", size);
fseek(fp, 0, SEEK_SET);
#endif could be possible to fix |
@bucanero AFAICT both |
When using
ftello()
with a big file (over 2GB), the returned value is invalid (.e.g0xffffffff88776655
) as if it suffered overflow from a 32-bit limit.I'd expect such behavior from
ftell()
, but sinceftello()
return aoff_t
type (64 bits) I'd have expected a valid value.Btw, using
stat()
on the same file and getting the size attribute returns the expected file size value.Example:
The text was updated successfully, but these errors were encountered: