struct stat64 problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ccfq
    New Member
    • Sep 2006
    • 3

    struct stat64 problem

    I have a problem with GCC and C.
    (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:

    Code:
    [B]struct stat64[/B] statbf;
    returns a "storage size of 'statbf' isn't known" error.

    My lame workaround is to open the large file:

    Code:
    [B]FILE[/B] *f;
    [B]uint64_t[/B] size;
    f = fopen64( name, "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
Working...