How to support Large file size with ofstream ?

S

shyam

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
 
J

Jack Klein

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top