@classmethod
def FromBuffer(cls, buffer):
    """Instantiate an EndCentralDirectory from this buffer."""
    if len(buffer) > cls.sizeof():
        end = len(buffer) - cls.sizeof() + 4
        while True:
            index = buffer.rfind(cls.magic_string, 0, end)
            if index < 0:
                break
            end_cd = cls(buffer[index:])
            if end_cd.IsValid():
                return end_cd, index
            end = index
    raise IOError('Unable to find EndCentralDirectory')
