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

How to support Large file size with ofstream ?

Hi All

I have a application which is basically a log manager and accepts log
messages from other processes and logs them in files ( one file per
process per day ). The application manages the creating of log files,
formatting the incoming log messages with proper time stamp and writing
the logs in the respective log files.

I am using C++ ofstream for doing the file operations in Linux 2.4 .

I want to implement large file support so that when the logfile size
reaches 2GB limit the system doesnt exit with signal SIGXFSZ.

I know that this works in C using -D_LARGEFILE_SOURCE flag.
But I want to know how to implement this in C++ , and using only
ofstream ?

I am not sure it it is possible that way without using mix of FILE and
ofstream

Any suggestions?

thanks in advance
Shyam

Oct 9 '06 #1
1 2861
On 9 Oct 2006 05:34:23 -0700, "shyam" <sh********@gmail.comwrote in
comp.lang.c++:
Hi All

I have a application which is basically a log manager and accepts log
messages from other processes and logs them in files ( one file per
process per day ). The application manages the creating of log files,
formatting the incoming log messages with proper time stamp and writing
the logs in the respective log files.

I am using C++ ofstream for doing the file operations in Linux 2.4 .

I want to implement large file support so that when the logfile size
reaches 2GB limit the system doesnt exit with signal SIGXFSZ.

I know that this works in C using -D_LARGEFILE_SOURCE flag.
But I want to know how to implement this in C++ , and using only
ofstream ?

I am not sure it it is possible that way without using mix of FILE and
ofstream

Any suggestions?

thanks in advance
Shyam
The C++ language does not set any limits on the size of a file. Any
limits that are set are by your particular compiler, its library, and
your operating system, not the language.

"-D_LARGEFILE_SOURCE" is not something defined by C or C++, but
something provided by your compiler, its library, and your operating
system.

The place to ask about overcoming such limitations is a group that
supports, surprise, surprise!, your compiler and operating system
combination.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Oct 10 '06 #2

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

Similar topics

7
by: Joseph | last post by:
Hi, I'm having bit of questions on recursive pointer. I have following code that supports upto 8K files but when i do a file like 12K i get a segment fault. I Know it is in this line of code. ...
3
by: Romain | last post by:
Hello, I am writing out a binary file. I figured that the number "10" is automaticaly converted to "OD OA" instead of "OD". "OD" and "OA" are line feed and carriage return. I know it does...
5
by: alex | last post by:
HI,all: I use ofstream of stl to manange a file, but how can I get size of the file? // open file std::ofstream * log = new std::ofstream( "test.log" ); // get size ???
3
by: Kat | last post by:
Ok my problem with this program is that currently it isn't overwriting a dummy TXT file I have set up to test the program. At one point it did however so I know it should work but now, for some...
6
by: Wes | last post by:
I'm running FreeBSD 6.1 RELEASE #2. The program is writting in C++. The idea of the program is to open one file as input, read bytes from it, do some bitwise operations on the bytes, and then...
5
by: B. Williams | last post by:
I need some assistance with random access file processing. I have a function that I would like to change from sequential file processing to random access. Thanks in advance. void...
14
by: JoeC | last post by:
I have been writing games and I also read about good programming techniques. I tend to create large objects that do lots of things. A good example I have is a unit object. The object controls...
13
by: liujiaping | last post by:
Hi, all. I have a dictionary-like file which has the following format: first 4 column 7 is 9 a 23 word 134 .... Every line has two columns....
21
by: pilafi | last post by:
Hallo guys!!I have a problem and i would like your help.I have to make a reader for a platform,where reads csv files.So, i made this read and its possible to read now csv files.But the problem is...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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
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...
0
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...

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.