Advertisement
Soneek

util.py

Dec 22nd, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import struct
  2.  
  3.  
  4. def readByte(file):
  5.     return struct.unpack("B", file.read(1))[0]
  6.  
  7. def readu16be(file):
  8.     return struct.unpack(">H", file.read(2))[0]
  9.  
  10. def readu16le(file):
  11.     return struct.unpack("<H", file.read(2))[0]
  12.    
  13. def readu32be(file):
  14.     return struct.unpack(">I", file.read(4))[0]
  15.  
  16. def readu32le(file):
  17.     return struct.unpack("<I", file.read(4))[0]
  18.  
  19. def readfloatbe(file):
  20.     return struct.unpack(">f", file.read(4))[0]
  21.  
  22. def readfloatle(file):
  23.     return struct.unpack("<f", file.read(4))[0]
  24.  
  25.  
  26.    
  27. def getString(file):
  28.     result = ""
  29.     tmpChar = file.read(1)
  30.     while ord(tmpChar) != 0:
  31.         result += tmpChar
  32.         tmpChar =file.read(1)
  33.     return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement