473,781 Members | 2,280 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

maximum file size of FOPEN

I tried to open some large files in my computer. (ram 512MB)

1. is there limitation of file size FOPEN?

2. if I have a file that is larger than the maximum size, how can I
open the file?

Nov 14 '05 #1
15 15487
In article <11************ **********@z14g 2000cwz.googleg roups.com>,
uremae <ur****@gmail.c om> wrote:
I tried to open some large files in my computer. (ram 512MB) 1. is there limitation of file size FOPEN?
No, not unless there is something unusual and system-specific.

There could, for example, -potentially- be issues with
opening a device or pseudo-device, if the device driver for some
reason decided it needed to take a snapshot into memory
(e.g., opening /dev/core might take a snapshot of kernel state,)
Any such behaviour would be outside the bounds of C: such
behaviour does not happen for plain files.

2. if I have a file that is larger than the maximum size, how can I
open the file?


Any such matter would be system specific. fopen() is all that
C itself provides.

It isn't usually a problem to *open* an existing large file: the
problem is usually in *reading* the large file. Some systems
are only able to read to about the 2 gigabyte mark, or are
allowed to read indefinitely but cannot position (ftell/fseek)
beyond 2 gigabytes without using system-specific calls.
--
"Never install telephone wiring during a lightning storm." -- Linksys
Nov 14 '05 #2

"uremae" <ur****@gmail.c om> wrote

1. is there limitation of file size FOPEN?

2. if I have a file that is larger than the maximum size, how can I
open the file?

There's ususally some limit, though it might be so large that there is no
chance of exceeding it.
If fopen() fails to open a huge file, or the read functions won't allow you
to read it all, the best solution is to look for lower-level system specific
calls. Sometimes you might be able to redesign your files so that they fall
within the limit.

However make sure that the size of the file really is the problem, not that
there is some hardware problem with the disk drive, or that the file is
corrupt in some way.
Nov 14 '05 #3
In article <d6**********@n wrdmz02.dmz.ncs .ea.ibs-infra.bt.com>,
Malcolm <re*******@btin ternet.com> wrote:
"uremae" <ur****@gmail.c om> wrote
1. is there limitation of file size FOPEN?

There's ususally some limit, though it might be so large that there is no
chance of exceeding it.


Could you give us an example of a system with such a limit, Malcolm ?

I have certainly run into systems whose filesize was limited
(with different limits for different filesystem types), but I
cannot think of anything in C or POSIX.1 or any implementation
that I have -encountered- that would fopen() for opening a
[plain] file for read once the file had made it on to the
filesystem.

Ability to read all of a large file is questionable, though:
the internal file position counter can overflow (e.g., if one
is NFS or SMB'ing over the contents of a file which resides on
a remote filesystem that supports much larger files than the local
system expects.)

And ability to position/ reposition in a large file is quite
questionable seeing as fseek() is limited to taking a 'long' for the
offset...
--
Beware of bugs in the above code; I have only proved it correct,
not tried it. -- Donald Knuth
Nov 14 '05 #4
On 19 May 2005 21:57:05 GMT, in comp.lang.c ,
ro******@ibd.nr c-cnrc.gc.ca (Walter Roberson) wrote:
In article <d6**********@n wrdmz02.dmz.ncs .ea.ibs-infra.bt.com>,
Malcolm <re*******@btin ternet.com> wrote:
"uremae" <ur****@gmail.c om> wrote

1. is there limitation of file size FOPEN?

There's ususally some limit, though it might be so large that there is no
chance of exceeding it.


Could you give us an example of a system with such a limit, Malcolm ?

I have certainly run into systems whose filesize was limited
(with different limits for different filesystem types), but I
cannot think of anything in C or POSIX.1 or any implementation
that I have -encountered- that would fopen() for opening a
[plain] file for read once the file had made it on to the
filesystem.


The file could exist on network attached storage which supports larger
file sizes than the local OS - f'rexample you could have Win95
locally, and be mapping a W2k3 or *nix drive.
..
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt >
Nov 14 '05 #5
then how can I read the large file that is larger than gigabye with
what system-specific calls in linux or unix.

Nov 14 '05 #6
In article <p7************ *************** *****@4ax.com>,
Mark McIntyre <ma**********@s pamcop.net> wrote:
On 19 May 2005 21:57:05 GMT, in comp.lang.c ,
ro******@ibd.n rc-cnrc.gc.ca (Walter Roberson) wrote:
In article <d6**********@n wrdmz02.dmz.ncs .ea.ibs-infra.bt.com>,
Malcolm <re*******@btin ternet.com> wrote:
"uremae" <ur****@gmail.c om> wrote 1. is there limitation of file size FOPEN? There's ususally some limit, though it might be so large that there is no
chance of exceeding it.
Could you give us an example of a system with such a limit, Malcolm ?

The file could exist on network attached storage which supports larger
file sizes than the local OS


I see that Malcolm was correct. Checking the opengroup.org fopen() man
page, I see that one of the defined error returns is

[EOVERFLOW]
The named file is a regular file and the size of the file
cannot be represented correctly in an object of type off_t.
--
"Never install telephone wiring during a lightning storm." -- Linksys
Nov 14 '05 #7
In article <11************ *********@g43g2 000cwa.googlegr oups.com>,
uremae <ur****@gmail.c om> wrote:
then how can I read the large file that is larger than gigabye with
what system-specific calls in linux or unix.


You are guaranteed up to (2 gigabytes - 1) in any conforming
unix system (provided the filesystem supports files that large.)

There is no standard unix interface for reading files whose
size cannot be represented as off_t .

In Linux, if your version of Linux has Large Files System support,
then you can open() using the O_LARGEFILE flag.
--
"Mathematic s? I speak it like a native." -- Spike Milligan
Nov 14 '05 #8
Walter Roberson wrote:
Ability to read all of a large file is questionable, though:
the internal file position counter can overflow (e.g., if one
is NFS or SMB'ing over the contents of a file which resides on
a remote filesystem that supports much larger files than the local
system expects.)
AFAICS, the counter can't overflow per se (this implies undefined
behaviour). Rather, an attempt to get the current file position can
fail.
And ability to position/ reposition in a large file is quite
questionable seeing as fseek() is limited to taking a 'long'
for the offset...


You are allowed to perform multiple seeks and keep your own file
position data.

--
Peter

Nov 14 '05 #9
uremae <ur****@gmail.c om> wrote:
then how can I read the large file that is larger than gigabye with
what system-specific calls in linux or unix.


The folks over in comp.os.linux.d evelopment.apps and comp.unix.progr ammer
would be more helpful since this is a really platform dependent thing.

On more recent Linux platforms you would typically define _FILE_OFFSET_BI TS
to 64 before you include _any_ standard or system header. This would then
automagically select the 64 bit interface allowing for > 2GB file access for
those interfaces which normally wouldn't be able to handle files that large.

For example:

gcc -D_FILE_OFFSET_B ITS=64 -o main main.c

- Bill
Nov 14 '05 #10

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

Similar topics

0
2266
by: Phil Powell | last post by:
// PROCESS XML CONTENT INTO DYNAMICALLY-NAMED ARRAYS foreach (array('mime', 'state', 'country') as $val) { $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, ${$val . 'XML'}, ${$val . 'XMLArray'}, $tags); xml_parser_free($parser); $myXMLArray = ${$val . 'XMLArray'}; for ($i = 1; $i < @sizeof($myXMLArray) - 1; $i++) { if ($myXMLArray) {
7
1712
by: pescott | last post by:
I am still struggling to get some files uploaded to a database as BLOB data. I have 5 includes which allows the user to upload 5 files, numbered accordingly. However, there are script errors. Duhh, why else would I post? Well, here goes: CODE $adres = trim (htmlspecialchars($_POST)); $verkocht = trim (htmlspecialchars($_POST)); $form_description1 = trim (htmlspecialchars($_POST));
4
5636
by: Jens Mittag | last post by:
Hi! In my code, I have an array of a structure, which I want to save to a binary file. When the array is just created, everything works fine, but when I change contents of the array, saving results in a file, which doesn't hold the information of the changed array anymore. I dont know why. Here is the code: /*
2
22608
by: Potiuper | last post by:
Question: Is it possible to use a char pointer array ( char *<name> ) to read an array of strings from a file in C? Given: code is written in ANSI C; I know the exact nature of the strings to be read (the file will be written by only this program); file can be either in text or binary (preferably binary as the files may be read repeatedly); the amount and size of strings in the array won't be known until run time (in the example I have it in...
1
8118
by: Alex | last post by:
Hello, I'm trying to write a little php script to transfert some files from a server to clients (web/http). It's working fin with small files. But transfering big files (try on 1Gb) failed! The transfert is stoped randomly (sometimes at 25%, sometimes at 75%,...). And I don't understand why?! :/
7
2652
by: lawrence k | last post by:
I've got a music studio for a client. Their whole studio is run with Macintosh computers. Macintosh computers allow file names to have open white spaces, such as "animal hospital.mp3". I have a download script, so customers on the website can download MP3s to their harddrive (rather than merely listen to it in their browsers):
4
3372
by: Giacomo | last post by:
Hello.. i'm using php on linux --version: PHP 5.2.5 (cli) (built: Apr 25 2008 18:40:41) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies and i'm experiencing unexpected behavior using fread with a binary file. Look at this code: i have a jpeg image of 2290 bytes long, but fread cannot read it correctly, like fgetc does:
13
10453
by: rohit | last post by:
Hi All, I am new to C language.I want to read integers from a text file and want to do some operation in the main program.To be more specific I need to multiply each of these integers with another set of integers stored in an array.It would be a great help if you could provide some code for it.I tried the function fscanf but by that I am able to read only the first integer of the text file.Please help me.
45
4466
by: Dennis | last post by:
Hi, I have a text file that contents a list of email addresses like this: "foo@yahoo.com" "tom@hotmail.com" "jerry@gmail.com" "tommy@apple.com" I like to
0
9636
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10139
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10075
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.