DM4 header encodes little endian as byte value 1 in the header
:return: 'big' or 'little' for use with python's int.frombytes function
'''
ifisinstance(endian,str):
returnendian
assert(isinstance(endian,int))
ifendian==1:
return'little'
return'big'
def_get_struct_endian_str(endian):
'''
DM4 header encodes little endian as byte value 1 in the header. However when that convention is followed the wrong values are read. So this implementation is reversed.
:return: '>' or '<' for use with python's struct.unpack function
'''
ifisinstance(endian,str):
ifendian=='little':
return'>'#Little Endian
else:
return'<'#Big Endian
else:
ifendian==1:
return'>'#Little Endian
else:
return'<'#Big Endian
defread_root_tag_dir_header_dm4(dmfile,endian):
'''Read the root directory information from a dm4 file.
File seek position is left at end of root_tag_dir_header'''