New file using Struct

This commit is contained in:
ultramagnus_tcv 2015-07-29 20:22:55 -05:00
parent 69a49be099
commit 1971d427a2
1 changed files with 15 additions and 0 deletions

15
Struct_decode.py Normal file
View File

@ -0,0 +1,15 @@
from struct import unpack
#Is File a SOS DRIVER file?
SOSfile = open('SOSCFFA.DRIVER', 'rb')
SOS = SOSfile.read(10)
filetype, offset = unpack('< 8s H', SOS)
print "Filetype is: %s. Offset is: %04x" % (filetype, offset)
#Seek to first driver
SOSfile.seek(offset,1)
SOS = SOSfile.read(2) # Read two bytes
marker = unpack('< H', SOS)
if marker == \x0000 :
SOSfile.close()