/* hpfs.cmd */

files = 'Object.h'

'@echo off'

if stream('typedstr.h', 'C', 'QUERY EXISTS') == '' then do
  say 'Already done'
  exit
end

say 'Renaming files'
'ren typedstr.h typedstream.h'
'ren NXConstS.h NXConstStr.h'

do i = 1 to words(files)
  file = word(files, i)
  say 'Patching' file
  'sed -f hpfs.sed >tmp' file
  if rc \= 0 then do
    say 'sed failed!'
    exit
  end
  'touch -r' file 'tmp'
  'del' file
  'move tmp' file '>nul'
end

say 'Done'
