hpn
30th September 2006, 10:16
I have an annoying problem with GCC and C, so if some of the coding gurus here is kind enough to help It will be much appreciated, cause extensive googling failed.
(I'm under Windows XP, CPU 32-bit Athlon XP., gcc version 3.4.5, mingw special)
Is there some simple way to return the size of a large file (2GB+) without opening it? GCC seems to not understand "struct stat64" (missing in the header "sys/stat.h")
Coding something like:
struct stat64 statbf;
returns a "storage size of 'statbf' isn't known" error.
My lame workaround is to open the large file:
FILE *f;
uint64_t size;
f = fopen64( nm, "rb" );
fseeko64( f, 0L, 2 );
size = ftello64( f );
fclose( f );
but opening just to get the size seems hacky plus it's about 10 times slower than using "struct stat" and statbf.st_size when processing a tree with thousands of files.
Thanks
(I'm under Windows XP, CPU 32-bit Athlon XP., gcc version 3.4.5, mingw special)
Is there some simple way to return the size of a large file (2GB+) without opening it? GCC seems to not understand "struct stat64" (missing in the header "sys/stat.h")
Coding something like:
struct stat64 statbf;
returns a "storage size of 'statbf' isn't known" error.
My lame workaround is to open the large file:
FILE *f;
uint64_t size;
f = fopen64( nm, "rb" );
fseeko64( f, 0L, 2 );
size = ftello64( f );
fclose( f );
but opening just to get the size seems hacky plus it's about 10 times slower than using "struct stat" and statbf.st_size when processing a tree with thousands of files.
Thanks