def find_real_file(dir, name, options)
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)
return if found.empty?
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]
candidates = found.map do |(f, _)|
" " + Sass::Util.pathname(f).relative_path_from(relative_to).to_s
end.join("\n")
raise Sass::SyntaxError.new("It's not clear which file to import for '@import \"\#{name}\"'.\nCandidates:\n\#{candidates}\nPlease delete or rename all but one of these files.\n")
else
candidates = found.map {|(f, _)| " " + File.basename(f)}.join("\n")
Sass::Util.sass_warn "WARNING: In \#{File.dirname(name)}:\n There are multiple files that match the name \"\#{File.basename(name)}\":\n\#{candidates}\n"
end
end
found.first
end