Class: Dir
- Inherits:
-
Object
- Object
- Dir
- Defined in:
- lib/supplement/dir.rb
Overview
supplement/dir.rb – More Dir methods
Class Method Summary collapse
-
.nuke!(n) ⇒ Object
:call-seq: Dir.nuke!( name) -> nil.
-
.rmpath(n) ⇒ Object
:call-seq: Dir.rmpath( name) -> nil.
Class Method Details
.nuke!(n) ⇒ Object
:call-seq:
Dir.nuke!( name) -> nil
Delete a directory, all its contents and all subdirectories. WARNING! This can cause serious damage.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/supplement/dir.rb', line 15 def nuke! n (new n).entries!.each { |e| p = File.join n, e if File.directory? p then nuke! p else File.unlink p end } rmdir n nil end |
.rmpath(n) ⇒ Object
:call-seq:
Dir.rmpath( name) -> nil
Delete as many empty directories as possible.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/supplement/dir.rb', line 33 def rmpath n case n when "/", "." then else if (new n).entries!.empty? then rmdir n d = File.dirname n rmpath d end end nil end |