Example #1
0
    def load(self, s: AbstractIO):
        self.name = s.get_widestr()
        self.kind, compressed = get_kind(s.get_uint())
        size = s.get_uint()

        if compressed:
            self.datatable = DataTable(get_size_by_kind(self.kind))
            tempbuf = Buffer.from_bytes(s.decompress(size))
            self.datatable.load(tempbuf, tempbuf.size())
            tempbuf.close()
            del tempbuf
        else:
            self.datatable = DataTable(get_size_by_kind(self.kind))
            self.datatable.load(s, size)
Example #2
0
    def load(self, s: AbstractIO):
        magic = s.get(4)
        if magic != b'STRG':
            s.close()
            raise Exception("Storage.load: wrong magic")

        version = s.get_uint()
        if version > 1:
            s.close()
            raise Exception("Storage.load: wrong version")

        if version == 1:
            tempbuf = Buffer.from_bytes(s.decompress())
            s.close()
            s = tempbuf

        for i in range(s.get_uint()):
            record = StorageRecord()
            record.load(s)
            self.records.append(record)