C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with ofstream::seekp

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Paolo
Guest





PostPosted: Tue Sep 26, 2006 9:10 am    Post subject: Problem with ofstream::seekp Reply with quote



Hi all!

I'm using ofstream and seekp to write a file. The problem is I have to
write a very big file, more than 4 Gb, but the streamoff that I have to
pass to seekp isn't a 64 bit int (it's a long int) so I can't use it!
Is it normal or there is some workaround for this?

Thank you
Back to top
Paolo
Guest





PostPosted: Wed Sep 27, 2006 9:10 am    Post subject: Re: Problem with ofstream::seekp Reply with quote



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!!!!!

Is there a way to use seekp with 64 bit integers?
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...

Thank you for your help!

Paolo
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.