From: Andrew Savige Date: 2007-08-12T17:05:41+09:00 Subject: Re: Sorting a logfile, how would you write it? --- William James wrote: > Of course. But I'm willing to take that miniscule chance when > I'm doing a write to a small file that takes a fraction of a > second. That may be an acceptable risk for a program written for private use. Not so for a production program. After all, impatient users often press [CTRL-C] in my experience, and that could cause corruption if it occurred while the file was being rewritten. Certainly, such a program would fail code review at my company for anything we send to our clients. > The question remains: doesn't using a temp file cause more > disk fragmentation than writing directly to the original file? Probably ... though correctness should come before performance (I'll refrain from quoting Donald Knuth at you ;-). And, in this case, any performance degradation with modern file systems should be negligible. Cheers, /-\ ____________________________________________________________________________________ Sick of deleting your inbox? Yahoo!7 Mail has free unlimited storage. http://au.docs.yahoo.com/mail/unlimitedstorage.html