def save_entries(entries, base_offset, prefix): entry_names = [] offsets = [] text_writer = BinaryIO() for entry in entries: if entry[:-1] == prefix: entry_names.append(entry[-1]) for i in range(len(entry_names)): text_writer.writeUInt32(0) for entry in entry_names: offsets.append(text_writer.tell() + base_offset) text_writer.writeString(entry) with text_writer.seek(0): text_writer.write(array.array('I', offsets).tostring()) return len(entry_names), text_writer
def save(self): """Save necessary information. NDSTool cleans up the rest""" writer = BinaryIO('\x00' * 0x200) writer.write(self.name) with writer.seek(0xC): writer.write(self.code) with writer.seek(0x10): writer.write('01') # Nintendo with writer.seek(0x60): writer.writeUInt32(0x7f7fff) writer.writeUInt32(0x7f1fff) writer.writeUInt32(0) writer.writeUInt32(0) writer.writeUInt32(0x051E) with writer.seek(0xA0): writer.write(self.base_code) writer.seek(0x200) return writer
def save(self, writer=None): """Creates a writer for this model Parameters ---------- writer : BinaryIO, optional Destination to write into. If not specified, a new IO will be created. Returns ------- writer : BinaryIO A new or modified writer that has this data in it """ writer = writer if writer is not None else BinaryIO() amount = self.get_size() writer.write( ctypes.string_at(ctypes.addressof(self._data), size=amount)) return writer
def save(self): """Save existing blob""" return BinaryIO(self.data)
def get_value(self): """String of this Archive""" writer = BinaryIO() return self.save(writer).getvalue()