# File lib/rubygems/source_info_cache.rb, line 342
  def try_file(path)
    return path if File.writable? path
    return nil if File.exist? path

    dir = File.dirname path

    unless File.exist? dir then
      begin
        FileUtils.mkdir_p dir
      rescue RuntimeError, SystemCallError
        return nil
      end
    end

    return path if File.writable? dir

    nil
  end