This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

writing large file


Hello,

I'm not sure where to send this question, so I apologize if this is not the
right place.
 
I'd like to work with files that are larger than 2GB.
 
This is my sample program : 
 
#include <iostream>
#include <fstream>
 
using namespace std;
 
typedef long long int filePos;
 
int main (int argc, char **argv){
 
    filePos vel=0;
    cout.precision(10);
 
    fstream
soubor("testFileSizeSoubor.jh",ios::in|ios::out|ios::binary|ios::trunc);
 
#define BUFSIZE 1024*1024*128
#define COUNT 8*3
 
    char* buffer=new char[BUFSIZE];
    if(buffer==0) throw std::bad_alloc();
 
    for(int i=0;i<COUNT;i++){
        soubor.write(buffer,BUFSIZE);
        vel=soubor.tellp().get_fpos_t();
        cout << (double) vel << endl;
    }
 
    delete[] buffer;
    soubor.close();
 
    return 0;
}
 
When the file size grows above 2GB I'm getting SIGXFS2 on file size limit.
Is it a problem of OS or libstdc++ or my code?
 
Thank you
Best regards 
Janus Hajek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]