Hi,
I think that you should change the type representing the
file size from 'long' to 'long long' or even better
'int64_t' defined in <inttypes.h>. There are files
larger than 2GB, so a 32-bit signed type is just not enough
and will result in errornous values.
regards,
Artur