$KCODE = 'SJIS'

Dir.glob('**/*'){|entry|
  case entry
  when /\.dof$/, /\.cfg$/
    $stderr.print "relative path #{entry}\n"
    lev = entry.split(/\//).size - 1
    backup = entry + '~'
    File.rename entry, backup
    open(backup){|i|
    open(entry, 'w'){|o|
      while line = i.gets
        line.gsub!(%r%c:\\apollo\\%i, '..\\'*lev)
        line.gsub!(%r%..\\src%i, ".")
        o.print line
      end
    }}
  end
}
