Hello,
this throws an exception Errno::EACCESS under Windows
ruby -r tempfile -e 'Tempfile.new("foo").unlink'
but works under Unixen. I think the behaviour ought to be consistent on
both. Closing the tempfile before unlinking it, seems to help (see
patch). What do you think?
Index: lib/tempfile.rb
===================================================================
RCS file: /src/ruby/lib/tempfile.rb,v
retrieving revision 1.19
diff -u -p -r1.19 tempfile.rb
--- lib/tempfile.rb 23 Jul 2003 16:37:35 -0000 1.19
+++ lib/tempfile.rb 5 May 2004 23:33:57 -0000
@@ -106,7 +106,10 @@ class Tempfile < SimpleDelegator
# file.
def unlink
# keep this order for thread safeness
- File.unlink(@tmpname) if File.exist?(@tmpname)
+ if File.exist?(@tmpname)
+ closed? or close
+ File.unlink(@tmpname)
+ end
@@cleanlist.delete(@tmpname) if @@cleanlist
end
alias delete unlink
--
lambda { |c| lambda { |f| f[f] } [ lambda { |f| c[lambda { |x| f[f][x] } ] }] }