1
0
mirror of https://github.com/blawar/ooot.git synced 2024-07-02 09:03:36 +00:00
ooot/tools/add_actor_header.py
2022-01-31 19:05:17 -05:00

29 lines
750 B
Python

import os.path
from pathlib import Path
removeHeaders = ['#include "actor_common.h"', '#include "z64global.h"', '#include "sfx.h"', '#include "sequence.h"', '#include "z64effect.h"']
def writeFile(path, buffer):
with open(path, 'r', encoding="UTF-8") as f:
if f.read() == buffer:
return
print('writing %s' % path)
with open(path, 'w', encoding="UTF-8") as f:
f.write(buffer)
header = '#include "actor_common.h"'
dir = 'src/overlays/'
for path in Path(dir).rglob('*.c'):
x = str(path).replace('\\', '/')
#print(x)
with open(x, 'r', encoding="UTF-8") as f:
buffer = f.read().replace('\r', '')
#if header not in buffer:
for i in removeHeaders:
buffer = buffer.replace(i + '\n', '')
writeFile(x, header + '\n' + buffer)