473,396 Members | 2,129 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,396 software developers and data experts.

How to deal with big-size files??

What can i do to open , write and seek in file with size 2 GB or more

I know that you r limited with int type size which is 32-bit but how
programs like gzip , zip read and write from files with big size like
2-GB

how can i break this limit in C or even C++
Dec 31 '07 #1
8 8118
On Dec 31 2007, 11:59*pm, "åäÏÇæì" <3D.v.Wo...@gmail.comwrote:
What can i do to open , write and seek in file with size 2 GB or more

I know that you r limited with int type size which is 32-bit but how
programs like gzip , zip read and write from files with big size like
2-GB

*how can i break this limit in C or even C++
In Win32, you can use LARGE_INTEGER structure, and the APIs support 64-
bit integers.
Many compilers have built-in support for 64-bit integers, such as
__int64 in Microsoft C++ compiler.
However, it seems that standard C functions do not support 64-bit
integers.
Dec 31 '07 #2
Some compilers provide big file support
Microsoft and other compilers like lcc-win provide special functions
like fseeki64 and other functions to cope with files bigger than
2GB under the windows system.
what about more than 2GB , windows or linux as example can deal with
more than 2GB and it's written in C++
how can they do that
Dec 31 '07 #3
هنداوى wrote:
>Some compilers provide big file support
Microsoft and other compilers like lcc-win provide special functions
like fseeki64 and other functions to cope with files bigger than
2GB under the windows system.

what about more than 2GB , windows or linux as example can deal with
more than 2GB and it's written in C++
how can they do that
bigger than 2GB means BIGGER (greater than). This means a file of
1000 GB if you wish!
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Dec 31 '07 #4
bigger than 2GB means BIGGER (greater than). This means a file of
1000 GB if you wish!
Is there is any method available in C/C++ or any language to deal with
that

Python for example manage variables types in this case is the size
will be infinite"limited to physical memory size" or also limited to
64-bit
Dec 31 '07 #5
åäÏÇæì wrote:
What can i do to open , write and seek in file with size 2 GB or more

I know that you r limited with int type size which is 32-bit but how
programs like gzip , zip read and write from files with big size like
2-GB

how can i break this limit in C or even C++
The size of an int isn't relevant; the relevant functions are fseek()
and ftell(), and they use long, not int.
'long' is only guaranteed to be at least 32 bits; it can be larger
than that, and on many systems it is. On systems where 'long' is a 64-
bit type, there is no problem (for now - wait a few decades and even
64 bits might not be enough).

I'm not very familiar with systems where files can be greater than
2GB, but long is too small to hold a file length, so I'll let others
tell you what to do in that case. However, in principle even when
'long' is only 32 bits, you could handle files longer than 2GB by
using fgetpos() and fsetpos() instead of fseek() and ftell(). The
interface is clumsier, but it's still workable. However, I know that
on at least some systems, the ability to work in that fashion to
handle files larger than 2GB is deliberately disabled; you have to use
special functions that are not defined by the C standard to access the
part of a long file that is after an offset of LONG_MAX.
Dec 31 '07 #6
On Dec 31, 9:48*am, jameskuy...@verizon.net wrote:
åäÏÇæì wrote:
What can i do to open , write and seek in file with size 2 GB or more
I know that you r limited with int type size which is 32-bit but how
programs like gzip , zip read and write from files with big size like
2-GB
*how can i break this limit in C or even C++

The size of an int isn't relevant; the relevant functions are fseek()
and ftell(), and they use long, not int.
'long' is only guaranteed to be at least 32 bits; it can be larger
than that, and on many systems it is. On systems where 'long' is a 64-
bit type, there is no problem (for now - wait a few decades and even
64 bits might not be enough).

I'm not very familiar with systems where files can be greater than
2GB, but long is too small to hold a file length, so I'll let others
tell you what to do in that case. However, in principle even when
'long' is only 32 bits, you could handle files longer than 2GB by
using fgetpos() and fsetpos() instead of fseek() and ftell(). The
interface is clumsier, but it's still workable. However, I know that
on at least some systems, the ability to work in that fashion to
handle files larger than 2GB is deliberately disabled; you have to use
special functions that are not defined by the C standard to access the
part of a long file that is after an offset of LONG_MAX.
Hence, the FAQ:

12.25: What's the difference between fgetpos/fsetpos and ftell/fseek?
What are fgetpos() and fsetpos() good for?

A: ftell() and fseek() use type long int to represent offsets
(positions) in a file, and may therefore be limited to offsets
of about 2 billion (2**31-1). The newer fgetpos() and
fsetpos()
functions, on the other hand, use a special typedef, fpos_t,
to
represent the offsets. The type behind this typedef, if
chosen
appropriately, can represent arbitrarily large offsets, so
fgetpos() and fsetpos() can be used with arbitrarily huge
files.
fgetpos() and fsetpos() also record the state associated with
multibyte streams. See also question 1.4.

References: K&R2 Sec. B1.6 p. 248; ISO Sec. 7.9.1,
Secs. 7.9.9.1,7.9.9.3; H&S Sec. 15.5 p. 252.
Dec 31 '07 #7
On Dec 31, 11:16*am, user923005 <dcor...@connx.comwrote:
On Dec 31, 9:48*am, jameskuy...@verizon.net wrote:


åäÏÇæì wrote:
What can i do to open , write and seek in file with size 2 GB or more
I know that you r limited with int type size which is 32-bit but how
programs like gzip , zip read and write from files with big size like
2-GB
*how can i break this limit in C or even C++
The size of an int isn't relevant; the relevant functions are fseek()
and ftell(), and they use long, not int.
'long' is only guaranteed to be at least 32 bits; it can be larger
than that, and on many systems it is. On systems where 'long' is a 64-
bit type, there is no problem (for now - wait a few decades and even
64 bits might not be enough).
I'm not very familiar with systems where files can be greater than
2GB, but long is too small to hold a file length, so I'll let others
tell you what to do in that case. However, in principle even when
'long' is only 32 bits, you could handle files longer than 2GB by
using fgetpos() and fsetpos() instead of fseek() and ftell(). The
interface is clumsier, but it's still workable. However, I know that
on at least some systems, the ability to work in that fashion to
handle files larger than 2GB is deliberately disabled; you have to use
special functions that are not defined by the C standard to access the
part of a long file that is after an offset of LONG_MAX.
thank's alot
that really the info(s) what i want
Dec 31 '07 #8
On Dec 31 2007, 6:17 pm, "åäÏÇæì" <3D.v.Wo...@gmail.comwrote:
Some compilers provide big file support
Microsoft and other compilers like lcc-win provide special functions
like fseeki64 and other functions to cope with files bigger than
2GB under the windows system.

what about more than 2GB , windows or linux as example can deal with
more than 2GB and it's written in C++
how can they do that
There is also open() and O_LARGEFILE as defined by POSIX.
Also, there might be some library to deal with large files.
Jan 1 '08 #9

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

Similar topics

2
by: Min | last post by:
I have seen so many pointing out "main" should explicitly return "int". Beside, the language spec or committee, or some guru said so, what is a BIG deal with it ? What difference does it make if...
21
by: Franco Gustavo | last post by:
Hi, Please help me to understand this, because I don't see what I'm missing. I was reading a lot of examples on Internet that explain that C# doesn't implement multiple inheritance it...
7
by: rbt | last post by:
The house almost always wins or are my assumptions wrong... import random amounts = results = count = 0 while count < 10:
44
by: Viken Karaguesian | last post by:
Hello all, On occasion I want to open hyperlinks (images, etc.) in a new window. In the past, I've used target="_blank" to open the link in a new window. However, using the "target" attribute...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.