mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/tempfile.rb (Tempfile::Remover): new class to replace
Tempfile.callback. [ruby-core:17824] [ruby-dev:39271] See [ruby-dev:39317] for the reason. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@24902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3d93c5198f
commit
001884f623
2 changed files with 29 additions and 19 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Sun Sep 13 22:13:35 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* lib/tempfile.rb (Tempfile::Remover): new class to replace
|
||||||
|
Tempfile.callback. [ruby-core:17824] [ruby-dev:39271]
|
||||||
|
See [ruby-dev:39317] for the reason.
|
||||||
|
|
||||||
Sun Sep 13 11:06:12 2009 Tanaka Akira <akr@fsij.org>
|
Sun Sep 13 11:06:12 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* lib/open-uri.rb (OpenURI::Meta#content_type_parse): strip quotes.
|
* lib/open-uri.rb (OpenURI::Meta#content_type_parse): strip quotes.
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Tempfile < DelegateClass(File)
|
||||||
end
|
end
|
||||||
|
|
||||||
@data = [tmpname]
|
@data = [tmpname]
|
||||||
@clean_proc = Tempfile.callback(@data)
|
@clean_proc = Tempfile::Remover.new(@data)
|
||||||
ObjectSpace.define_finalizer(self, @clean_proc)
|
ObjectSpace.define_finalizer(self, @clean_proc)
|
||||||
|
|
||||||
@tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)
|
@tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)
|
||||||
|
@ -155,12 +155,15 @@ class Tempfile < DelegateClass(File)
|
||||||
end
|
end
|
||||||
alias length size
|
alias length size
|
||||||
|
|
||||||
class << self
|
class Remover # :nodoc:
|
||||||
def callback(data) # :nodoc:
|
def initialize(data)
|
||||||
pid = $$
|
@pid = $$
|
||||||
lambda{
|
@data = data
|
||||||
if pid == $$
|
end
|
||||||
path, tmpfile, cleanlist = *data
|
|
||||||
|
def call(arg=nil)
|
||||||
|
if @pid == $$
|
||||||
|
path, tmpfile, cleanlist = *@data
|
||||||
|
|
||||||
print "removing ", path, "..." if $DEBUG
|
print "removing ", path, "..." if $DEBUG
|
||||||
|
|
||||||
|
@ -172,9 +175,10 @@ class Tempfile < DelegateClass(File)
|
||||||
|
|
||||||
print "done\n" if $DEBUG
|
print "done\n" if $DEBUG
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class << self
|
||||||
# If no block is given, this is a synonym for new().
|
# If no block is given, this is a synonym for new().
|
||||||
#
|
#
|
||||||
# If a block is given, it will be passed tempfile as an argument,
|
# If a block is given, it will be passed tempfile as an argument,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue