> 2007/7/12, Ronald Fischer <ronald.fischer / venyon.com>:
> > > >     file=Tempfile.new('.tempreq','/thome/requests')
> > > >     file << '....' # populate the file
> > > >     path=file.path # remember the generated filename
> > > >     file.close
> > > >     result=path+'.xml' # add desired extension to the filename
> > > >     File.rename(path,result) # rename file
> > > >     at_exit { File::delete(result) } # remove file at exit
> > > >
> > > > When the exit handler jumps into action, I get however 
> the following
> > > > error:
> > > >
> > > > H:\thome\grubylib/TfwCommon.rb:433:in `delete': 
> Permission denied -
> > > > /thome/requests/.tempr
> > > > eq.3176.0.xml (Errno::EACCES)

> In that case rather use your own mechanism.  That's too far away from
> tempfile's functionality. 

I found a solution based on an idea posted at

 
http://marsorange.com/articles/2006/07/17/of-mogrify-ruby-tempfile-dynam
ic-class-definitions

which allowed me to use most of Tempfile functionality with only
providing
minimal own code:

require 'tempfile'
class XMLTempfile <Tempfile
  def make_tmpname(basename, n)
    sprintf('%s%d-%d.xml', basename, $$, n)
  end
end

....

    file=XMLTempfile.new('.tempreq',TFW_REQDIR)
    file << '.....'
    result=file.path
    file.close

Ronald