# File lib/linecache.rb, line 449
  def update_cache(filename, opts=false)
      if opts.kind_of?(Hash)
        use_script_lines = opts[:use_script_lines]
      else
        use_script_lines = opts
        opts = {:use_script_lines => use_script_lines}
      end

    return nil unless filename

    @@file_cache.delete(filename)
    path = File.expand_path(filename)

    if use_script_lines
      list = [filename]
      list << @@file2file_remap[path] if @@file2file_remap[path]
      list.each do |name|
        if !SCRIPT_LINES__[name].nil? && SCRIPT_LINES__[name] != true
          begin
            stat = File.stat(name)
          rescue
            stat = nil
          end
          raw_lines = SCRIPT_LINES__[name]
          lines = {:plain => raw_lines}
          lines[opts[:output]] =
            highlight_string(raw_lines.join, opts[:output]).split(/\n/) if
            opts[:output]
          @@file_cache[filename] = LineCacheInfo.new(stat, nil, lines, path, nil)
          @@file2file_remap[path] = filename
          return true
        end
      end
    end

    if File.exist?(path)
      stat = File.stat(path)
    elsif File.basename(filename) == filename
      # try looking through the search path.
      stat = nil
      for dirname in $:
        path = File.join(dirname, filename)
        if File.exist?(path)
            stat = File.stat(path)
            break
        end
      end
      return false unless stat
    end
    begin
      # (GF) rewind does not work in JRuby with a jar:file:... filename
      # (GF) read file once and only create string if required by opts[:output]
      lines = { :plain => File.readlines(path) }
      if opts[:output]
        lines[opts[:output]] = highlight_string(lines[:plain].join, opts[:output]).split(/\n/)
      end
    rescue
      ##  print '*** cannot open', path, ':', msg
      return nil
    end
    @@file_cache[filename] = LineCacheInfo.new(File.stat(path), nil, lines,
                                               path, nil)
    @@file2file_remap[path] = filename
    return true
  end