After reading numerous report on stackoverflow, I decide to go with FILE* (over std::fstream) to manipulate quickly my binary files. Furthermore, I needed to truncate my file during the process (_chsize or ftruncate), which will work only with a file descriptor (fileno call).
So I am trying to have something like this working (C++):
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
static inline off_t FTello(FILE *stream)
{
#if _WIN32
#if defined(__MINGW32__)
return ftell( stream ); // 32bits
#else
return _ftelli64( stream );
#endif
#else
return ftello( stream );
#endif
}
However this is clearly not working on Visual Studio. I could not find anywhere in the documentation a way to change the size of off_t at compilation time.
It would be tempting to have a signature like this (I assume I have C99: stdint.h):
static inline int64_t FTello(FILE *stream)
What others have been doing ?
For reference, here is what I have been reading, which seems to indicate FILE* provide better performance: