Module: Astrails::Safe::TmpFile
- Defined in:
- lib/astrails/safe/tmp_file.rb
Class Method Summary collapse
Class Method Details
.cleanup ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/astrails/safe/tmp_file.rb', line 11 def self.cleanup begin FileUtils.remove_entry_secure tmproot rescue ArgumentError => e if e. =~ /parent directory is world writable/ puts "\n\n********************************************************************************\nIt looks like you have wrong permissions on your TEMP directory. The usual\ncase is when you have world writable TEMP directory withOUT the sticky bit.\n\nTry \"chmod +t\" on it.\n\n********************************************************************************\n\n" else raise end end @tmproot = nil end |
.create(name) {|file| ... } ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/astrails/safe/tmp_file.rb', line 35 def self.create(name) # create temp directory file = Tempfile.new(name, tmproot) yield file file.close @keep_files << file # so that it will not get gcollected and removed from filesystem until the end file.path end |
.tmproot ⇒ Object
7 8 9 |
# File 'lib/astrails/safe/tmp_file.rb', line 7 def self.tmproot @tmproot ||= Dir.mktmpdir end |