473,395 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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?

Sep 29 '07 #1
3 6616
On 2007-09-29 11:51, zou wrote:
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.

--
Erik Wikström
Sep 29 '07 #2
On Sep 29, 2:54 am, Erik Wikström <Erik-wikst...@telia.comwrote:
On 2007-09-29 11:51, zou wrote:
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.

--
Erik Wikström

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.

--
Leandro Melo
Sep 29 '07 #3
On 2007-09-30 00:57, ltcmelo wrote:
On Sep 29, 2:54 am, Erik Wikström <Erik-wikst...@telia.comwrote:
>On 2007-09-29 11:51, zou wrote:
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.

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.

--
Erik Wikström
Sep 29 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Juergen Marsch | last post by:
Hi, writing files > 2G with standard library iostream classes results in "... file size limit exeeded." Compiling my program with "-D_FILE_OFFSET_BITS=64" doesn't make any difference. If you...
4
by: =?Utf-8?B?U2VyZ2Vp?= | last post by:
Dear staff Can I get your assistance with \3GB (LARGEADDRESSAWARE) switch in mixed mode process built by VS 2008, please? I have a mixed mode application: C# GUI calling native C++ DLL through...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.