From: "ara.t.howard" Date: 2008-09-23T01:27:24+09:00 Subject: Re: at_exit handler *except* for fatal runtime error On Sep 22, 2008, at 9:51 AM, DMisener wrote: > Simple problem: > > Create a tentative output working file. If the program exits > "cleanly" then rename the work file > to its "final" name. If not leave the work file for possible > examination. > > Ideally this File.open_tentative_output_file would be plug > "compatible" with the simple File.open > (i.e. support modes and blocks). class TentativeFile Ext = 'tentative' def open path, *a, &b super "#{ path }.#{ Ext }", *a, &b end def close final = path.to_s.sub %r/[.]#{ Ext }$/, '' super ensure File.rename path, final unless $! end end a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama