Lines Matching refs:fd

474     def _skip_to(self, fd, offset):  argument
481 if fd.tell() > offset:
483 (offset, fd.tell()))
484 fd.write(tools.GetBytes(self._erase_byte, offset - fd.tell()))
486 def _pad_to(self, fd, offset): argument
493 self._align_to(fd, self._align)
494 upto = fd.tell()
501 fd.write(cbf.get_data_and_offset()[0])
502 self._skip_to(fd, offset)
504 def _align_to(self, fd, align): argument
516 offset = align_int(fd.tell(), align)
518 self._skip_to(fd, offset)
556 def _write_header(self, fd, add_fileheader): argument
564 if fd.tell() > self._header_offset:
566 (self._header_offset, fd.tell()))
568 self._pad_to(fd, self._header_offset)
574 fd.write(struct.pack(FILE_HEADER_FORMAT, FILE_MAGIC, len(hdr),
577 fd.write(name)
578 self._header_offset = fd.tell()
579 fd.write(hdr)
580 self._align_to(fd, self._align)
582 fd.write(hdr)
592 fd = io.BytesIO()
596 self._write_header(fd, add_fileheader=self._add_fileheader)
597 self._skip_to(fd, self._contents_offset)
604 self._pad_to(fd, align_int_down(offset, self._align))
605 pos = fd.tell()
607 fd.write(data)
608 self._align_to(fd, self._align)
611 self._write_header(fd, add_fileheader=self._add_fileheader)
614 self._pad_to(fd, self._base_address or self._size - 4)
616 fd.write(struct.pack('<I', rel_offset & 0xffffffff))
618 return fd.getvalue()
660 with io.BytesIO(self.data) as fd:
662 if not self._find_and_read_header(fd, len(self.data)):
664 fd.seek(self.cbfs_offset)
668 cfile = self._read_next_file(fd)
674 def _find_and_read_header(self, fd, size): argument
688 orig_pos = fd.tell()
689 fd.seek(size - 4)
690 rel_offset, = struct.unpack('<I', fd.read(4))
692 fd.seek(pos)
693 found = self._read_header(fd)
697 fd.seek(pos)
698 found = self._read_header(fd)
701 fd.seek(orig_pos)
704 def _read_next_file(self, fd): argument
715 file_pos = fd.tell()
716 data = fd.read(FILE_HEADER_LEN)
724 pos = fd.tell()
725 name = self._read_string(fd)
734 compress = self._read_attr(fd, file_pos, attr, offset)
741 fd.seek(cbfs_offset, io.SEEK_SET)
743 self._read_header(fd)
745 data = fd.read(STAGE_LEN)
750 cfile.data = fd.read(cfile.data_len)
752 data = fd.read(size)
759 fd.read(size)
768 pad = (self.align - fd.tell() % self.align) % self.align
769 fd.seek(pad, io.SEEK_CUR)
773 def _read_attr(cls, fd, file_pos, attr, offset): argument
794 fd.seek(file_pos + attr, io.SEEK_SET)
796 pos = fd.tell()
797 hdr = fd.read(8)
802 data = hdr + fd.read(alen - 8)
814 def _read_header(self, fd): argument
827 pos = fd.tell()
828 data = fd.read(HEADER_LEN)
840 def _read_string(cls, fd): argument
854 data = fd.read(FILENAME_ALIGN)