Class: Dir

Inherits:
Object
  • Object
show all
Defined in:
lib/appswarm/tools.rb

Class Method Summary collapse

Class Method Details

.mkdir_save(*args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/appswarm/tools.rb', line 25

def self.mkdir_save(*args)
    return if File.directory?(*args)
  begin
    self.mkdir(*args)
  rescue Object=>e
    d=*args
    p=File.split(d)[0]
    self.mkdir_save(p) if p!=d
    self.mkdir(*args)
  end
end

.rmdir_f(dir) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/appswarm/tools.rb', line 37

def self.rmdir_f(dir)
  if File.directory?(dir)
    files=Dir[File.join(dir,"*")]
    files.each{|f|rmdir_f(f)}
    Dir.delete(dir)
  elsif File.file?(dir)
    File.delete(dir)
  end
end