Chad wrote:
I was wondering what the best method of updating a file was.
heres my prob, ive got a file with say 1million urls and I want to
take the first 10,000 and store them in memory. I want to 10k of urls
to be taken out an the file to be updated. is there anyway i could
move the beggining of the file?? What would b the most efficient way
of updating the file??
There's not way in standard C++ (nor in most implementations) to remove
anything from the start or middle of a file. Some systems provide
extensions that let you truncate files, but that's OT here. Your only
way to do this is to copy the file. Load your lines into memory, update
them, write them out to a new file, deal with the next batch or copy the
remaining portion of the original file to the new one.
A performance improvement would be if you had a way to categorized the
URLs, so you could break things up into smaller files.
Brian Rodenborn