473,811 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

iostream and files larger than 4GB

Hi,

I am relative new to C++ regarding it's functions and libraries. I need to
access files larger than 4GB which is AFAIK not possible with the STL
iostream - at least not if using a 32 bit compiler. iostream was my
favorite as my code has to work on files as well as memory buffers...

Could somebody please help me what functions/classes are the best in this
case?

BTW: I am currently using Visual C++ 2008 on Win32, but if possible I want
to write my code as "portable as possible".

Robert
Jul 21 '08 #1
19 7383
Robert Kochem wrote:
I am relative new to C++ regarding it's functions and libraries. I need to
access files larger than 4GB which is AFAIK not possible with the STL
iostream - at least not if using a 32 bit compiler. iostream was my
favorite as my code has to work on files as well as memory buffers...
Have you actually tried and failed, or is that only your speculation?
Could somebody please help me what functions/classes are the best in this
case?

BTW: I am currently using Visual C++ 2008 on Win32, but if possible I want
to write my code as "portable as possible".
AFAIK, even standard C Library functions like fread and fseek should
work with large files. And since C++ I/O streams are relatively thin
wrappers around C streams, those are expected to work just as well.
Write a program, see if you get it to work, if not, post your code and
explain the situation.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 21 '08 #2
Victor Bazarov schrieb:
Robert Kochem wrote:
>I am relative new to C++ regarding it's functions and libraries. I need to
access files larger than 4GB which is AFAIK not possible with the STL
iostream - at least not if using a 32 bit compiler. iostream was my
favorite as my code has to work on files as well as memory buffers...

Have you actually tried and failed, or is that only your speculation?
If you get a "possible loss of data" warning when feeding seekg() with an
64 bit integer - what would you expect?
AFAIK, even standard C Library functions like fread and fseek should
work with large files. And since C++ I/O streams are relatively thin
wrappers around C streams, those are expected to work just as well.
Write a program, see if you get it to work, if not, post your code and
explain the situation.
It may work for files, but can I work with them on memory streams?

Robert
Jul 21 '08 #3
Robert Kochem wrote:
Victor Bazarov schrieb:
>Robert Kochem wrote:
>>I am relative new to C++ regarding it's functions and libraries. I need to
access files larger than 4GB which is AFAIK not possible with the STL
iostream - at least not if using a 32 bit compiler. iostream was my
favorite as my code has to work on files as well as memory buffers...
Have you actually tried and failed, or is that only your speculation?

If you get a "possible loss of data" warning when feeding seekg() with an
64 bit integer - what would you expect?
I expect not to use seekg then. Or switch to a better implementation of
the library.
>
>AFAIK, even standard C Library functions like fread and fseek should
work with large files. And since C++ I/O streams are relatively thin
wrappers around C streams, those are expected to work just as well.
Write a program, see if you get it to work, if not, post your code and
explain the situation.

It may work for files, but can I work with them on memory streams?
I don't know what those are, sorry.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 21 '08 #4
Hi,

Most 32 bit OS'es have a limitation of 2GB (maybe 4GB I am not sure about
that) per file. If the OS can handle both like for instance sun V440 or
ubuntu 64 or lots of others you can compile with m64 with gcc (and link to
64 versions of all libraries) and usually have the full 64 bit range.
Sometimes you have to add something like LARGE_FILE_SUPP ORT from the top of
my memory.

I havent' tried but maybe the same applies to 64 bit MS-Windows.
Regards, Ron AF Greve

http://www.InformationSuperHighway.eu

"Robert Kochem" <ro****@mailueb erfall.dewrote in message
news:1b******** *************** *******@40tude. net...
Hi,

I am relative new to C++ regarding it's functions and libraries. I need to
access files larger than 4GB which is AFAIK not possible with the STL
iostream - at least not if using a 32 bit compiler. iostream was my
favorite as my code has to work on files as well as memory buffers...

Could somebody please help me what functions/classes are the best in this
case?

BTW: I am currently using Visual C++ 2008 on Win32, but if possible I want
to write my code as "portable as possible".

Robert

Jul 21 '08 #5
Victor Bazarov wrote:
>If you get a "possible loss of data" warning when feeding seekg() with an
64 bit integer - what would you expect?

I expect not to use seekg then. Or switch to a better implementation of
the library.
That is easy to say - but what else to use?
>It may work for files, but can I work with them on memory streams?

I don't know what those are, sorry.
May be that was not the correct name in the C++ realm: I need an
abstraction of the underlaying data source. My code have to work on files
as well as on memory buffers and I call a stream using a memory buffer as
source a memory stream.

Robert
Jul 21 '08 #6
Ron AF Greve schrieb:
Most 32 bit OS'es have a limitation of 2GB (maybe 4GB I am not sure about
that) per file.
Sorry, but I can't believe that. Do you really mean that e.g. a 32bit Linux
filesystem can not handle files larger than 4GB?

Robert
Jul 21 '08 #7
tni
Visual C++ iostream doesn't work with large files, not even on x64. See
the following discussion (still true for VS 2005 at least):

http://archive.netbsd.se/?ml=opensce...5-08&m=1634957
Jul 21 '08 #8
Hi,

In the past there certainly was a time it couldn't. Currently I haven't a
pure 32 bit linux version although I could test with 64 and compiling for 32
(maybe tomorrow) And I am sure a lot of OS'es indeed don't. Lookup your
flavor and search for large file support.

Regards, Ron AF Greve

http://www.InformationSuperHighway.eu

"Robert Kochem" <ro****@mailueb erfall.dewrote in message
news:13******** *************** *****@40tude.ne t...
Ron AF Greve schrieb:
>Most 32 bit OS'es have a limitation of 2GB (maybe 4GB I am not sure about
that) per file.

Sorry, but I can't believe that. Do you really mean that e.g. a 32bit
Linux
filesystem can not handle files larger than 4GB?

Robert

Jul 21 '08 #9
Robert Kochem wrote:
Victor Bazarov wrote:
>>If you get a "possible loss of data" warning when feeding seekg() with an
64 bit integer - what would you expect?
I expect not to use seekg then. Or switch to a better implementation of
the library.

That is easy to say - but what else to use?
A different implementation. Check out 'STLport', Dinkumware...
>>It may work for files, but can I work with them on memory streams?
I don't know what those are, sorry.

May be that was not the correct name in the C++ realm: I need an
abstraction of the underlaying data source. My code have to work on files
as well as on memory buffers and I call a stream using a memory buffer as
source a memory stream.
So, are you going to write some kind of wrappers for C++ streams and
your own buffers, or are you going to provide your own streambuf
implementations that you're going to plug into C++ streams?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 21 '08 #10

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

Similar topics

10
89408
by: John Tiger | last post by:
Can anybody have idea about the difference between #include <iostream.h> and #include <iostream>. Is later one valid statement on any compiler. I tried compiling on MSVC second statement give compilation error as #include expect filename. Anu help would be appreciated. thanx, John
6
6168
by: shailesh kumar | last post by:
Hi, I need to design data interfaces for accessing files of very large sizes efficiently. The data will be accessed in chunks of fixed size ... My data interface should be able to do a random seek in the file, as well as sequential access block by block.... One aspect of the usage of this interface is that there is quite good chance of accessing same blocks again and again by the application..
0
2098
by: PeterB | last post by:
Hi! I am using the script below to download files, that are in a non-public directory, from my site. The "smaller files" section works for smaller files. However when the files are getting larger, it won't work! I'm not sure what the size limit is, or if it is some kind of timeout, which would mean very small files if the connection is slow (I'm working against a server on the LAN). When I try to download larger files with the "small...
1
3847
by: Pradyot Dhulipala | last post by:
Hi, I am using ns2.26 with the Makefile using C++ compiler version c++ (GCC) 3.2.2 (Mandrake Linux 9.1 3.2.2-3mdk). When I use iostream.h in a simple program and compile with c++ everything works except I get a deprecated warning. Using the find command I get the location of iostream.h as /usr/include/c++/3.2.2/iostream. Also in my makefile the list of includes are as follows INCLUDES = \
1
4576
by: ya man | last post by:
when i use #include <iostream.h> in some files i get lots of error messages of the kind 'ambiguous symbol this is solved when i use #include <iostream why is that ? and can i use #include <iostream.h> in some way examples to the error messages c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\streamb.h(90): error C2872: 'ios' : ambiguous symbo c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\streamb.h(90): error C2872:...
1
2245
by: Phong Pham | last post by:
I'm creating a web page to upload files, but I'm having a problem uploading files larger than about 3.5 mb. Anything smaller than 3.5 mb is ok. If the file is larger, it doesn't generate an error, it just doesn't do anything. Can anyone show me how to fix that problem? I'm also trying to trap any files larger than 3.5 mb to let the user know that they can't upload files larger than that: If MyUpload.PostedFile.ContentLength > 3500000...
1
3310
by: KJ | last post by:
I am using the System.Compression.GZipStream class, and I noticed that in certain cases, the resultant compressed file is actually larger than the original. This is almost a constant when compressing already-compressed formats such as jpeg. Another less-consistent example of this behavior is found in the case of compressing TIFFs, wherein some files end up greatly compressed (the larger ones up to 93% compression ratio) and others end up...
1
2144
by: lars.uffmann | last post by:
Hello everyone! I just debugged a pretty huge project, eliminating basically every memory leak that would occur with the current configuration files, at least according to the mtrace() tool from the library <mcheck.h>. Now the very last bugs I seem to be incapable of eliminating are: - 0x000000000061f460 Free 387310 was never alloc'd 0x2aaaab053b53 - 0x000000000061f040 Free 387311 was never alloc'd 0x2aaaab053b53
0
2675
by: ll | last post by:
I'm working with 'pure ASP upload' script which is designed to redirect to an alert/error message, should a file larger than the set limit be attempted to be uploaded. The problem is that, while smaller files do upload successfully, the script does not catch the larger files and rather than a specific error message in Firefox (and IE7), I just get the following: ------------------------------------ The connection was reset The...
0
9730
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...
1
10403
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
10136
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
9208
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...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
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();...
0
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4341
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
3020
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.