Module: Ftpd::TempDir

Defined in:
lib/ftpd/temp_dir.rb

Overview

Create temporary directories that will be removed when the program exits.

Class Method Summary collapse

Class Method Details

.makeObject

Create a temporary directory, returning its path. When the program exists, the directory (and its contents) are removed.



11
12
13
14
15
16
17
18
# File 'lib/ftpd/temp_dir.rb', line 11

def make
  Dir.mktmpdir.tap do |path|
    at_exit do
      FileUtils.rm_rf path
      Dir.rmdir path if File.exists?(path)
    end
  end
end