🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #7646

Random access files under TC++???

#7646
From: Utz-Uwe Haus
Date: Wed, 20 Jan 1993 18:53
22 lines
1574 bytes
Hello,
I'm currently writing a small database for a friend's company and encountered
the following problem: 
1) I save the records in a fstream file, build 2 indexes for easier search
(everything okay so far)
2) When I try to change the content of a record (read it, change the 
appropriate data and try to write it back, it gets appended to the end of the 
file, although I opened the file ios::out (I also tried ios::out|ios::app and a
seekg to the required position and ios::out|ios::ate and seekg()). In addition
to the wrong position for the rewrite the file sometimes is corrupted 
afterwards, making read-access for my build_index() - function impossible.

If there is some general error in my concept - (or some fine c++-specific I
missed ) *please* let me know. 
If there is some code available for automatic RandomAccessFiles - that would be
even better (sorry - I can't ftp, but mail is okay)!!
P.s. My last idea would be to copy all preceding records to a new file, append
the new one and copy the rest of the original file and then rename to the 
original, but thats pretty disk-intensive, right :->>>?

Utz-Uwe Haus
root%pse@chamber.in-berlin.de
Technical Details
Message-ID: <1993Jan20.185339.19456@chamber.in-berlin.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!math.fu-berlin.de!fub!einoed!bitcave!chamber.in-berlin.de!hausutzu

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!math.fu-berlin.de!fub!einoed!bitcave!chamber.in-berlin.de!hausutzu
From: hausutzu@chamber.in-berlin.de (Utz-Uwe Haus)
Subject: Random access files under TC++???
Message-ID: <1993Jan20.185339.19456@chamber.in-berlin.de>
Organization: Zombie's Burial Chamber, Berlin, West Germany.
Date: Wed, 20 Jan 1993 18:53:39 GMT
Lines: 23