class Sass::Importers::Filesystem

def find_real_file(dir, name, options)

Returns:
  • ((String, Symbol)) - A filename-syntax pair.

Parameters:
  • name (String) -- The filename to search for.
  • dir (String) -- The directory relative to which to search.
def find_real_file(dir, name, options)
  # On windows 'dir' or 'name' can be in native File::ALT_SEPARATOR form.
  dir = dir.gsub(File::ALT_SEPARATOR, File::SEPARATOR) unless File::ALT_SEPARATOR.nil?
  name = name.gsub(File::ALT_SEPARATOR, File::SEPARATOR) unless File::ALT_SEPARATOR.nil?
  found = possible_files(remove_root(name)).map do |f, s|
    path = if dir == "." || Sass::Util.pathname(f).absolute?
             f
           else
             "#{escape_glob_characters(dir)}/#{f}"
           end
    Dir[path].map do |full_path|
      full_path.gsub!(REDUNDANT_DIRECTORY, File::SEPARATOR)
      [Sass::Util.cleanpath(full_path).to_s, s]
    end
  end.flatten(1)
  if found.empty? && split(name)[2].nil? && File.directory?("#{dir}/#{name}")
    return find_real_file("#{dir}/#{name}", "index", options)
  end
  if found.size > 1 && !@same_name_warnings.include?(found.first.first)
    found.each {|(f, _)| @same_name_warnings << f}
    relative_to = Sass::Util.pathname(dir)
    if options[:_from_import_node]
      # If _line exists, we're here due to an actual import in an
      # import_node and we want to print a warning for a user writing an
      # ambiguous import.
      candidates = found.map do |(f, _)|
        "  " + Sass::Util.pathname(f).relative_path_from(relative_to).to_s
      end.join("\n")
      raise Sass::SyntaxError.new(<<MESSAGE)
ot clear which file to import for '@import "#{name}"'.
ates:
idates}
 delete or rename all but one of these files.
E
    else
      # Otherwise, we're here via StalenessChecker, and we want to print a
      # warning for a user running `sass --watch` with two ambiguous files.
      candidates = found.map {|(f, _)| "    " + File.basename(f)}.join("\n")
      Sass::Util.sass_warn <<WARNING
G: In #{File.dirname(name)}:
e are multiple files that match the name "#{File.basename(name)}":
idates}
G
    end
  end
  found.first
end