# File lib/chef/mixin/find_preferred_file.rb, line 25
      def load_cookbook_files(cookbook_id, file_type)
        unless file_type == :remote_file || file_type == :template
          raise ArgumentError, "You must supply :remote_file or :template as the file_type"
        end
        
        cl = Chef::CookbookLoader.new
        cookbook = cl[cookbook_id]
        raise NotFound unless cookbook

        files = Hash.new
        
        cookbook_method = nil
        
        case file_type
        when :remote_file
          cookbook_method = :remote_files
        when :template
          cookbook_method = :template_files
        end
                
        cookbook.send(cookbook_method).each do |rf|
          full = File.expand_path(rf)
          name = File.basename(full)
          case file_type
          when :remote_file
            rf =~ /^.+#{Regexp.escape(cookbook_id)}[\\|\/]files[\\|\/](.+?)[\\|\/]#{Regexp.escape(name)}/
          when :template
            rf =~ /^.+#{Regexp.escape(cookbook_id)}[\\|\/]templates[\\|\/](.+?)[\\|\/]#{Regexp.escape(name)}/
          end
          singlecopy = $1
          files[full] = {
            :name => name,
            :singlecopy => singlecopy,
            :file => full,
          }
        end
        Chef::Log.debug("Preferred #{file_type} list: #{files.inspect}")
        
        files
      end