By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,234 Members | 1,889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,234 IT Pros & Developers. It's quick & easy.

struct stat64 problem

P: 3
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:

Expand|Select|Wrap|Line Numbers
  1. struct stat64 statbf;
returns a "storage size of 'statbf' isn't known" error.

My lame workaround is to open the large file:

Expand|Select|Wrap|Line Numbers
  1. FILE *f;
  2. uint64_t size;
  3. f = fopen64( name, "rb" );
  4. fseeko64( f, 0L, 2 );
  5. size = ftello64( f );
  6. 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
Sep 30 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.