On 4/24/07, Tim Pease <tim.pease / gmail.com> wrote:
> On 4/24/07, Daniel Berger <djberg96 / gmail.com> wrote:
> > Hi all,
> >
> > Just curious - why was Ruby's temporary file handling class
> > (tempfile.rb) written in pure Ruby instead of using the tmpfile()
> > function? That function appears to be supported on most platforms,
> > including MS Windows.
> >
> > Are there file locking or threading issues I'm not aware of?
> >
> > The tmpfile() function does have the advantage of deleting itself when
> > all references to it are gone, instead of waiting until the Ruby
> > process itself dies. Perhaps there's no real advantage to that,
> > though?
> >
>
> The Ruby Tempfile class creates a finalizer that will delete the temp
> file when it is collected by the garbage collector; the Ruby Tempfile
> also deletes the temp file when it is closed. Your paragraph above
> makes it sound like this is not the case.

I was basing my comment on the Pickaxe 2, p. 741 which says,
"...temporary files are automatically deleted when the Ruby process
terminates".

Regards,

Dan