mirror of
https://github.com/michaelcmartin/Ophis.git
synced 2024-12-22 03:29:55 +00:00
Have .incbin take an optional offset and length for source bytes.
This commit is contained in:
parent
1df8ad465d
commit
b843ba9ba9
@ -38,11 +38,20 @@ def pragmaRequire(ppt, line, result):
|
|||||||
def pragmaIncbin(ppt, line, result):
|
def pragmaIncbin(ppt, line, result):
|
||||||
"Includes a binary file"
|
"Includes a binary file"
|
||||||
filename = line.expect("STRING").value
|
filename = line.expect("STRING").value
|
||||||
|
offset = 0
|
||||||
|
size = -1
|
||||||
|
if str(line.lookahead(0)) == ",":
|
||||||
|
line.pop()
|
||||||
|
offset = line.expect("NUM").value
|
||||||
|
if str(line.lookahead(0)) == ",":
|
||||||
|
line.pop()
|
||||||
|
size = line.expect("NUM").value
|
||||||
line.expect("EOL")
|
line.expect("EOL")
|
||||||
if type(filename)==str:
|
if type(filename)==str:
|
||||||
try:
|
try:
|
||||||
f = file(filename, "rb")
|
f = file(filename, "rb")
|
||||||
bytes = f.read()
|
f.seek(offset)
|
||||||
|
bytes = f.read(size)
|
||||||
f.close()
|
f.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
Err.log ("Could not read "+filename)
|
Err.log ("Could not read "+filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user