# File lib/fog/local/models/storage/file.rb, line 48 def destroy requires :directory, :key ::File.delete(path) if ::File.exists?(path) dirs = path.split(::File::SEPARATOR)[0...-1] dirs.length.times do |index| dir_path = dirs[0..-index].join(::File::SEPARATOR) if dir_path.empty? # path starts with ::File::SEPARATOR next end # don't delete the containing directory or higher if dir_path == service.path_to(directory.key) break end pwd = Dir.pwd if ::File.exists?(dir_path) && ::File.directory?(dir_path) Dir.chdir(dir_path) if Dir.glob('*').empty? Dir.rmdir(dir_path) end Dir.chdir(pwd) end end true end