I don’t know of any OSes that provide a bulletproof way to remove files when the process quits (or crashes), but the TemporaryFile class does its best to emulate that kind of behaviour.
Ha! Now that must have been there for some time as I see it in the online docs. SO HOW HAVE I NOT NOTICED??
I basically wrote this class for my own purposes not too long ago! It has the exact same functionality, though it does also a couple of extra functions, e.g. to check to see if it actually needs to be copied (i.e. if both files are identical, you don’t need to do anything), or if the target file is read-only [e.g. SVN locked]. Particularly useful when working on something that exports lots of data into an SVN asset folder, etc…
Some OSes keep the temp directory in memory (solaris does that, some linux distros do that). It’s a good way to clean stuff up, each reboot the temp directory gets purged no questions asked. Wish that windows could do that but i don’t know of any way to mount a piece of memory as a directory (under dos there used be a ramdisk command don’t knwo how modern widoze do that).
I think it’s a good idea cause it’s fast, but there is one thing to remember, you need to make sure it’s limited to a certain size.