This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Rats, I posted something once but can't find it now. In short, the idea is to seek() a position in the file, read or overwrite some number of bytes. This works nicely with fixed length records. If you know every record is exactly 40 bytes long, you can calculate the position for record n, read 40 bytes, overwrite those bytes with changes. You can build an external index that maps keys to record numbers and do primitive indexed IO. Unfortunately you can't insert any bytes, so new records always go on the end. You can't delete any bytes either, so if you "delete" a record you can wipe out the bytes and keep a list of "available" record slots for future writes. Hey, I found a part of the class I made. I was doing Test First coding, adding one function at a time. This was about half done, I think:
[ October 02, 2003: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi