def trans(i, o)
while line = i.gets
  line.gsub!(/\b(Define|Output)CompoClass\b/, '\1PersistentClass')
  o.print line
end
end

text_exts = %w[
  pas
  dpr
]

def run(src)
  tmp = src + '~'
  File.rename src, tmp
  open(tmp, 'r'){|i|
  open(src, 'w'){|o|
    trans i, o
  }}
end

Dir.glob('**/*'){|entry|
  pos = entry.rindex('.')
  next if pos.nil?
  ext = entry[pos+1..-1]
  if text_exts.include? ext
    $stderr.print "run #{entry}\n"
    run entry
  end
}
