Paolo said:
I'm going to explain better:
I have to write a big file to disk. I used ofstream and something
like
int dim = 1024 * 1024;
ch = new char[dim];
os.write(ch,dim);
Then I had to use seekp to find the position of a certain buffer,
because I receive packets with the buffer to write, the lenght of
the
buffer and the offset from the beginning of the file.
The problem is that the file could be bigger than 4 Gb, so when I
use
seekp I get an error, or better it doesnt work. For example
long long int big = (long long int)5 * 1024 * 1024 * 1024;
os.seekp(big,ios_base::beg);
cout << os.tellp();
The output of this piece of code is -1!!!!!
That indicates a failure.
Is there a way to use seekp with 64 bit integers?
Only on systems that has a 64 bit long. The long long type isn't (yet)
part of the C++ standard, so the library can't really use it.
If not, I think I'll have to try to use os.open(filename,
ios_base::ate) (it gets me to the end of file rigth??), but first I
wanted to try seekp, because I wouldn't have to save a non aligned
packet in memory...
How large is the file really? Is it *much* larger that 4 GB? If not,
you could perhaps divide your offset into a few separate seeks, moving
4 GB at a time. Or seek from ios_base::cur, or ios_base::end?
Bo Persson