def _write_wrapped_codestream(self, ofile, box):
<EOL>if len(self.box) == <NUM_LIT:0>:<EOL><INDENT>ofile.write(struct.pack('<STR_LIT>', self.length + <NUM_LIT:8>))<EOL>ofile.write(b'<STR_LIT>')<EOL>with open(self.filename, '<STR_LIT:rb>') as ifile:<EOL><INDENT>ofile.write(ifile.read())<EOL><DEDENT>return<EOL><DEDENT>offset = box.offset<EOL>if offset == -<NUM_LIT:1>:<EOL><INDENT>if self.box[<NUM_LIT:1>].brand == '<STR_LIT>':<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>raise IOError(msg)<EOL><DEDENT>jp2c = [_box for _box in self.box if _box.box_id == '<STR_LIT>']<EOL>offset = jp2c[<NUM_LIT:0>].offset<EOL><DEDENT>with open(self.filename, '<STR_LIT:rb>') as ifile:<EOL><INDENT>ifile.seek(offset)<EOL>read_buffer = ifile.read(<NUM_LIT:8>)<EOL>L, T = struct.unpack_from('<STR_LIT>', read_buffer, <NUM_LIT:0>)<EOL>if T != b'<STR_LIT>':<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise IOError(msg)<EOL><DEDENT>if L == <NUM_LIT:0>:<EOL><INDENT>L = os.path.getsize(ifile.name) - ifile.tell() + <NUM_LIT:8><EOL><DEDENT>elif L == <NUM_LIT:1>:<EOL><INDENT>read_buffer = ifile.read(<NUM_LIT:8>)<EOL>L, = struct.unpack('<STR_LIT>', read_buffer)<EOL><DEDENT>ifile.seek(offset)<EOL>read_buffer = ifile.read(L)<EOL>ofile.write(read_buffer)<EOL><DEDENT>
Write wrapped codestream.