Class: Net::SFTP::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/depengine/publisher/dweb.rb

Instance Method Summary collapse

Instance Method Details

#rm_r!(path, options = {}) ⇒ Object



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/depengine/publisher/dweb.rb', line 222

def rm_r!(path, options={})
  @rm_depth = 0 if @rm_depth.nil?
  self.dir.entries(path).each do |entry|

    next if entry.name == '.' or entry.name == '..'

    child_path = File.join(path, entry.name)

    if self.lstat!(child_path).directory?

      @rm_depth = @rm_depth + 1
      self.rm_r!(child_path)
      @rm_depth = @rm_depth - 1
    else
      self.remove!(child_path)
    end
  end

  if @rm_depth != 0 or options[:delete_root]
    self.rmdir!(path)
  end
end