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' can be in native File::ALT_SEPARATOR form
  dir = dir.gsub(File::ALT_SEPARATOR, File::SEPARATOR) unless File::ALT_SEPARATOR.nil?
  found = possible_files(remove_root(name)).map do |f, s|
    path = (dir == "." || Pathname.new(f).absolute?) ? f : "#{dir}/#{f}"
    Dir[path].map do |full_path|
      full_path.gsub!(REDUNDANT_DIRECTORY, File::SEPARATOR)
      [full_path, s]
    end
  end
  found = Sass::Util.flatten(found, 1)
  return if found.empty?
  if found.size > 1 && !@same_name_warnings.include?(found.first.first)
    found.each {|(f, _)| @same_name_warnings << f}
    relative_to = Pathname.new(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 {|(f, _)| "  " + Pathname.new(f).relative_path_from(relative_to).to_s}.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