Help how to get file size of larger file(>2G)?

Z

zou

there is a file which is very large,

we can use stat to get a file size(<2G),
struct stat buf;
stat("file", &buf);
long s=(long)stat.st_size;

but stat::st_size is type of off_t(typedef long),
so how about a file larger than 2G?
 
G

Guest

there is a file which is very large,

we can use stat to get a file size(<2G),
struct stat buf;
stat("file", &buf);
long s=(long)stat.st_size;

but stat::st_size is type of off_t(typedef long),
so how about a file larger than 2G?

stat() is POSIX, not C++ so you are off topic. Further more the only
requirement I could find on off_t was that it should be a signed
integral type, so it might just as well be a long long or an int. The
type of off_t is platform dependent, so if your platform uses a 32 bit
long and off_t is a long then you can not work with files larger than 2
GiB. For more information contact your platform vendor.
 
L

ltcmelo

stat() is POSIX, not C++ so you are off topic. Further more the only
requirement I could find on off_t was that it should be a signed
integral type, so it might just as well be a long long or an int. The
type of off_t is platform dependent, so if your platform uses a 32 bit
long and off_t is a long then you can not work with files larger than 2
GiB. For more information contact your platform vendor.


Hi.

If you're working with gcc, you might want to take a look at
http://www.delorie.com/gnu/docs/glibc/libc_285.html. There's a
compiler flag (_FILE_OFFSET_BITS) which allows you to work with
functions like lstat64, fstat64, and others, in 32-bit environment.
 
G

Guest

Hi.

If you're working with gcc, you might want to take a look at
http://www.delorie.com/gnu/docs/glibc/libc_285.html. There's a
compiler flag (_FILE_OFFSET_BITS) which allows you to work with
functions like lstat64, fstat64, and others, in 32-bit environment.

Please do not quote signatures.

Actually the link you posted have nothing to do with gcc, but rather the
GNU C library implementation, and while it is probably shipped with gcc
many platforms uses their own (like the BSD systems, and probably
Solaris too). Of course all of those have the ability to work with files
larger than 2 GiB, but those ways are platform specific and the OP
should ask in a group discussing the system for more information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top