All right, I made some minor changes:
will return correct values for files between 0 bytes and 4 GB.
A return value of 0 can mean two things: the size is either 0, or the handle is invalid.
/* Clear errno. */
stdioSET_ERRNO( 0 );
uxLength = ff_filelength( pxFile );
if( ( uxLength != 0 ) || ( stdioGET_ERRNO() == 0 ) )
/* Length equals to uxLength. */
/* Invalid handle. */
Also I introduced a new low-level function that splits up the result and the file length:
/* Use the following function in case files may get larger than 2 GB. */
int32_t FF_GetFileSize( FF_FILE *pFile, uint32_t *pulSize );
And more importantly:
now works correctly with sizes and offsets larger than 2GB.
Here below I attach 3 files, which are a copy of the ‘160919’ release along with mentioned changes.