This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
writing large file
- From: "Hajek, Janus" <Janus dot Hajek at skoda-auto dot cz>
- To: "'gcc-help at gcc dot gnu dot org'" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 11 Oct 2004 15:50:10 +0200
- Subject: 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