mirror of
https://github.com/michaelcmartin/Ophis.git
synced 2025-01-05 03:32:05 +00:00
Catch IOError in .incbin and .charmapbin pragmas.
This commit is contained in:
parent
5392f4c2d4
commit
a1cc6db760
@ -43,9 +43,13 @@ def pragmaIncbin(ppt, line, result):
|
|||||||
filename = line.expect("STRING").value
|
filename = line.expect("STRING").value
|
||||||
line.expect("EOL")
|
line.expect("EOL")
|
||||||
if type(filename)==str:
|
if type(filename)==str:
|
||||||
f = file(filename, "rb")
|
try:
|
||||||
bytes = f.read()
|
f = file(filename, "rb")
|
||||||
f.close()
|
bytes = f.read()
|
||||||
|
f.close()
|
||||||
|
except IOError:
|
||||||
|
Err.log ("Could not read "+filename)
|
||||||
|
return
|
||||||
bytes = [IR.ConstantExpr(ord(x)) for x in bytes]
|
bytes = [IR.ConstantExpr(ord(x)) for x in bytes]
|
||||||
result.append(IR.Node(ppt, "Byte", *bytes))
|
result.append(IR.Node(ppt, "Byte", *bytes))
|
||||||
|
|
||||||
@ -72,9 +76,13 @@ def pragmaCharmapbin(ppt, line, result):
|
|||||||
filename = line.expect("STRING").value
|
filename = line.expect("STRING").value
|
||||||
line.expect("EOL")
|
line.expect("EOL")
|
||||||
if type(filename)==str:
|
if type(filename)==str:
|
||||||
f = file(filename, "rb")
|
try:
|
||||||
bytes = f.read()
|
f = file(filename, "rb")
|
||||||
f.close()
|
bytes = f.read()
|
||||||
|
f.close()
|
||||||
|
except IOError:
|
||||||
|
Err.log ("Could not read "+filename)
|
||||||
|
return
|
||||||
if len(bytes)==256:
|
if len(bytes)==256:
|
||||||
currentcharmap = bytes
|
currentcharmap = bytes
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user