ruby遍历文件夹

def get_file_list(path)  
  Dir.entries(path).each do |sub|         
    if sub != '.' && sub != '..'  
      if File.directory?("#{path}/#{sub}")  
        puts "[#{sub}]"  
        get_file_list("#{path}/#{sub}")  
      else  
        puts "  |--#{sub}"  
      end  
    end  
  end  
end 

posted on 2012-09-29 16:07  张飞_  阅读(2868)  评论(0编辑  收藏  举报

导航