Ruby/File Directory/tmpdir

Материал из Wiki.crossplatform.ru

(Различия между версиями)
Перейти к: навигация, поиск
м (1 версия)
 

Текущая версия на 17:57, 13 сентября 2010

Dir.tmpdir provides the path to the temporary directory on the current system

require "tmpdir"
puts Dir.tmpdir



use Dir.tmpdir with File.join to create a platform-independent way of creating a temporary file:

require "tmpdir"
tempfilename = File.join(Dir.tmpdir, "myapp.dat")
tempfile = File.new(tempfilename, "w")
tempfile.puts "This is only temporary"
tempfile.close
File.delete(tempfilename)