# File lib/rb-inotify/notifier.rb, line 176
    def watch(path, *flags, &callback)
      return Watcher.new(self, path, *flags, &callback) unless flags.include?(:recursive)
      Dir.entries(path).each do |d|
        next if d == '.' || d == '..'
        d = File.join(path, d)
        watch(d, *flags, &callback) if File.directory?(d)
      end

      rec_flags = [:create, :moved_to]
      return watch(path, *((flags - [:recursive]) | rec_flags)) do |event|
        callback.call(event) if flags.include?(:all_events) || !(flags & event.flags).empty?
        next if (rec_flags & event.flags).empty? || !event.flags.include?(:isdir)
        watch(event.absolute_name, *flags, &callback)
      end
    end