# File lib/homesick/utils.rb, line 156
    def each_file(castle, basedir, subdirs)
      absolute_basedir = Pathname.new(basedir).expand_path
      inside basedir do
        files = Pathname.glob('{.*,*}').reject do |a|
          ['.', '..'].include?(a.to_s)
        end
        files.each do |path|
          absolute_path = path.expand_path
          castle_home = castle_dir(castle)

          # make ignore dirs
          ignore_dirs = []
          subdirs.each do |subdir|
            # ignore all parent of each line in subdir file
            Pathname.new(subdir).ascend do |p|
              ignore_dirs.push(p)
            end
          end

          # ignore dirs written in subdir file
          matched = false
          ignore_dirs.uniq.each do |ignore_dir|
            if absolute_path == castle_home.join(ignore_dir)
              matched = true
              break
            end
          end
          next if matched

          relative_dir = absolute_basedir.relative_path_from(castle_home)
          home_path = home_dir.join(relative_dir).join(path)

          yield(absolute_path, home_path)
        end
      end
    end