class Tins::Find::Finder

def find(*paths)

def find(*paths)
  block_given? or return enum_for(__method__, *paths)
  paths.collect! { |d| d.dup }
  while path = paths.shift
    path = prepare_path(path)
    catch(:prune) do
      stat = path.finder_stat or next
      visit_path?(path) and yield path
      if stat.directory?
        ps = protect_from_errors { Dir.entries(path) } or next
        ps.sort!
        ps.reverse_each do |p|
          next if p == "." or p == ".."
          next if !@show_hidden && p.start_with?('.')
          p = File.join(path, p)
          paths.unshift p.untaint
        end
      end
    end
  end
end

def initialize(opts = {})

def initialize(opts = {})
  @show_hidden     = opts.fetch(:show_hidden)     { true }
  @raise_errors    = opts.fetch(:raise_errors)    { false }
  @follow_symlinks = opts.fetch(:follow_symlinks) { true }
  opts[:suffix].full? { |s| @suffix = [*s] }
end

def prepare_path(path)

def prepare_path(path)
  path = path.dup.taint
  path.extend PathExtension
  path.finder = self
  path
end

def protect_from_errors(errors = Find::EXPECTED_STANDARD_ERRORS)

def protect_from_errors(errors = Find::EXPECTED_STANDARD_ERRORS)
  yield
rescue errors
  raise_errors and raise
  return
end

def visit_path?(path)

def visit_path?(path)
  @suffix.nil? || @suffix.include?(path.suffix)
end