class Utils::Find::ConfigurableFinder
def find(*paths, &block)
def find(*paths, &block) block_given? or return enum_for(__method__, *paths) paths.map! do |d| File.exist?(d) or raise Errno::ENOENT d.dup end while file = paths.shift catch(:prune) do file = prepare_file(file) visit_file?(file) and yield file begin s = stat(file) or next rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG next end if s.directory? then begin tried = false fs = Dir.entries(file) rescue Errno::EMFILE tried and raise close_files tried = true retry rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG next end fs.sort! fs.reverse_each do |f| next if f == "." or f == ".." f = File.join(file, f) paths.unshift f.untaint end end end end end