Subj : Deleting a record
To   : Sean Dennis
From : Scott Little
Date : Thu Sep 29 2005 09:19 pm

[ 28 Sep 05 21:42, Sean Dennis wrote to All ]


SD> I'm working on a new BBS door for my system and I need it to be able
SD> to delete a record from a file.  This is a typed file and only
SD> contains five fields for each record.  I'm not wanting to have to read
SD> the file, remove the one record, then rewrite the file again (kinda
SD> the long way around).  Any suggestions?

Have a Deleted attribute on each record.  If you also want to avoid repacking
the database periodically, keep an index file that maps out which records are
deleted so you can reuse them (but double check anyway, ie. seek the record,
read it, check it, overwrite it).

If you know you only need to delete one record, then you can iterate over every
subsequent record, copying it over the previous, then truncate the last record.


-- Scott Little  [fidonet#3:712/848 / [email protected]]

--- GoldED+/W32 1.1.5-20050419
* Origin: Cyberia: 100% Grade "A" mansteak baby. (3:712/848)