Quote:
Originally Posted by TheFluff
_fseeki64() and _ftelli64() are what you want but who knows if they're available in your ancient runtime
(looks like they're not, VS2005 or newer I think)
|
Either that, or just use the
_fstati64() function, which avoids having to move the file pointer around. Also you don't need to go down to the Win32 API this way.
It appears to be available in VS 6.0:
http://msdn.microsoft.com/en-us/libr...=vs.60%29.aspx
Code:
#include <sys/stat.h>
__int64 getFileSize64(FILE *const fp)
{
struct _stati64 stat;
if(_fstati64(_fileno(fp), &stat) != 0)
{
return -1; /*some error occurred*/
}
return stat.st_size;
}
Quote:
Originally Posted by StainlessS
I'm not altogether happy about mixing eg file handles and FILE*, but will investigate all things suggested.
|
On Windows, each
FILE* has an associated "native" operating system
HANDLE, which you can get via
_get_osfhandle(), if you really need to.
It is returned as an
intptr_t, but you can typecast to
HANDLE safely. I would still prefer the
fstat()-based solution, since it's cross-platform.