Re: How can I do a 100% bullet proof 'Save'?
From: Norm Dresner (ndrez_at_att.net)
Date: 09/24/04
- Next message: Scott McPhillips [MVP]: "Re: How can I decompile Managed Cpp code?"
- Previous message: vsganti: "Multicolumn listbox behaving wwird in VC7.1"
- In reply to: Simon: "Re: How can I do a 100% bullet proof 'Save'?"
- Next in thread: Alexander Grigoriev: "Re: How can I do a 100% bullet proof 'Save'?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 24 Sep 2004 20:46:25 GMT
"Simon" <sorde@gotadsl.co.uk> wrote in message
news:4153e126$0$52238$65c69314@mercury.nildram.net...
> Norm (& others)
> The advantage of your approach over mine is therefore that 2 things have
to
> go wrong in the same operation for the bad result (wrongly named original
> file) to occur. And as there is no reason to expect that these failures
> would be in any way related to one another, that would be exceptionally
bad
> luck.
>
> However, the disadvantage of your approach is that there is slightly more
to
> go wrong. On my approach, the bad result can only arise if the final
rename
> fails (which is exactly what happened). On your approach, if either the
> delete file fails, or the final rename, the bad result will arise.
>
(Norm:) With my approach:
1. Rename old file
2. Write new file
3. Delete old file
If the delete fails, you still have a good new file written to the disk.
The only bad side-effect is having the extra file there. And I have no
final rename -- you write the new file with the correct name in the first
place.
There's still a cascade of failures possible if the write fails and then
the renaming of the old file back to the original name fails too, you're
left with a situation in which the file has the wrong name -- but it's still
there.
This method is pretty much safe against power failures too as long as
you can detect if the "new" file is bad.
I'm not sure that there is a completely foolproof method -- anything's going
to be susceptible to corruption if the power fails at exactly the wrong
time. Pretty much the only way to guard against that is to copy the
original file to removable media which the user takes out of the computer
before anything else is done.
Don't shoot for 100% safe; settle for 99.9% -- it's much easier on your
mental health.
Norm
- Next message: Scott McPhillips [MVP]: "Re: How can I decompile Managed Cpp code?"
- Previous message: vsganti: "Multicolumn listbox behaving wwird in VC7.1"
- In reply to: Simon: "Re: How can I do a 100% bullet proof 'Save'?"
- Next in thread: Alexander Grigoriev: "Re: How can I do a 100% bullet proof 'Save'?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|