|
From: Earl K. <eh...@go...> - 2005-03-10 07:09:24
|
>>In comparing various packages that provide an UNIX-like under Windows, I
>>found that the stat() function in the MINGW clib does not return the proper
>>file size for files over 4 gigabytes.
>
>Yes. The documentation page for _stat() (on MSDN) does also describe
>_stati64(), which should give better results (as would GetFileSize()).
The sys/stat.h header for MINGW contains a prototype for _stati64(). There
also appears to be a _stati64() in the libraries included with MINGW.
Nonetheless, when I wrote a programme that used stat() and _stati64(), the
two nominally different routines seemed to return exactly the same (wrong)
file size for my 4.8 gigabyte test file. This makes me wonder if the MINGW
library _stati64() is really a different routine or just a disguised call
to the bog standard stat() function.
The code for my programme is appended below.
EHK
#include <stdio.h>
#include <sys/stat.h>
main( int argc, char *argv[] )
{
int ix;
struct stat sb;
struct _stati64 sx;
if( argc <= 1 ) {
printf("teststat filename(s)\n");
exit(0);
}
for( ix = 1; ix < argc; ix++ ) {
printf("%32.32s ",argv[ix]);
if(stat(argv[ix],&sb)) {
printf("%s\n","failed");
}
else {
printf("%10lu ",sb.st_size);
printf("%s",ctime(&sb.st_mtime));
}
printf("%32.32s ",argv[ix]);
if(_stati64(argv[ix],&sx)) {
printf("%s\n","failed");
}
else {
printf("%10lu ",sx.st_size);
printf("%s",ctime(&sx.st_mtime));
}
}
exit(0);
}
|