import struct


def _read_int(f, b):
    """
    Read an integer of a specified number of bytes from the filestream f
    """
    if b == 1:
        return struct.unpack('<B', f.read(b))[0]
    elif b == 2:
        return struct.unpack('<H', f.read(b))[0]
    elif b == 4:
        return struct.unpack('<I', f.read(b))[0]
    elif b == 8:
        return struct.unpack('<Q', f.read(b))[0]