Message-ID: <31899BE4.7159@public1.guangzhou.gd.cn> Date: Fri, 03 May 1996 14:38:44 +0900 From: Wang TianXing Organization: No Organization MIME-Version: 1.0 To: nate CC: djgpp AT delorie DOT com Subject: Re: gxx bug? binary files References: Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 7bit 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