Mail Archives: djgpp/1996/05/03/04:34:02
nate wrote:
>
> > [snip]
> >
> > > //modify temp_person (make it 66) and write it back to object 50 in file
> > > temp_file.open(FILE_NAME, ios::in|ios::out|ios::binary|ios::nocreate);
> >
> > Change that line to:
> >
> > temp_file.open(FILE_NAME, ios::in|ios::out|ios::app|ios::binary);
> >
> > libg++ 2.7.1 truncates the file when it sees 'out' without 'app'. And,
> > 'nocreate' is neither a standard thing nor a promise that the file will
> > not be truncated.
>
> Thanks for your response, I just tried your idea. Unfortunately, this
> APPENDS the file (as one might expect) and fails to update the file in
> the positing that I am trying to update. It seems silly that libg++
> 2.7.1 would include such a serious error. I'm off to search for DJGPP
> libg++ version 2.7.2, if you know if it exists, please inform me. thanks..
Sorry, I overlooked something. I think the only workaround might be to change
the source code in \djgpp\gnu\libgplus.271\libio\filebuf.cc:
if ((mode & (int)ios::trunc) ||
((!(mode & (int)ios::app)) && (mode & (int)ios::out)))
posix_mode |= O_TRUNC;
to:
if ((mode & (int)ios::trunc) ||
((!(mode & int(ios::app|ios::in))) && (mode & (int)ios::out)))
posix_mode |= O_TRUNC;
and rebuild the libiostr.a. Warning: this is also an untested one. :)
Regards,
Wang TianXing
- Raw text -