[darcs-users] DeleteFile on Windows (was: Re: hashed-storage work now merged in (woo!))
Zooko Wilcox-O'Hearn
zooko at zooko.com
Thu Oct 8 23:13:27 UTC 2009
On Thursday,2009-10-08, at 16:47 , Jason Dagit wrote:
> This appears to assume:
> * On windows you can move a file even if it is open
Not generally, no. The same rule that prevents you from deleting an
open file also prevents you from moving it.
The idiom I use is "If you're letting a finalizer do something, that
means you don't really care if it never gets done." (credit to JP
Calderone for teaching me this).
So, instead I have an explicit "clean up this thing" procedure that I
call when I know I'm done with the resource, and as an additional
"belt and suspenders" I sometimes have a finalizer that invokes that
explicit cleanup procedure.
This means that you have to figure out whether something else is also
using the same resource, in case that something else isn't done with
it. This doesn't turn out to be hard in practice.
The general moral is that garbage collection is great for managing
resources that are entirely inside the programming language runtime,
e.g. non-shared memory, but not great for managing resources that
have to be shared with things outside of the programming language
runtime, e.g. files.
Regards,
Zooko
More information about the darcs-users
mailing list