示例#1
0
 def read(self, address, size):
     assert size > 0
     missing = self._feed(address + size)
     if missing:
         size = self._size - address
         if size <= 0:
             return 0, '', True
     d = []
     i = lowerBound(self.fragments, lambda x: x[0] <= address)
     a, fa, fs = self.fragments[i-1]
     a -= address
     fa -= a
     fs += a
     s = None
     while True:
         n = min(fs, size)
         u, v, w = self.stream.read(fa, n)
         assert not w
         if s is None:
             s = u
         else:
             assert not u
         d += [ v ]
         size -= n
         if not size:
             return s, ''.join(d), missing
         a, fa, fs = self.fragments[i]
         i += 1
示例#2
0
 def read(self, address, size):
     assert size > 0
     missing = self._feed(address + size)
     if missing:
         size = self._size - address
         if size <= 0:
             return 0, '', True
     d = []
     i = lowerBound(self.fragments, lambda x: x[0] <= address)
     a, fa, fs = self.fragments[i - 1]
     a -= address
     fa -= a
     fs += a
     s = None
     while True:
         n = min(fs, size)
         u, v, w = self.stream.read(fa, n)
         assert not w
         if s is None:
             s = u
         else:
             assert not u
         d += [v]
         size -= n
         if not size:
             return s, ''.join(d), missing
         a, fa, fs = self.fragments[i]
         i += 1
示例#3
0
 def getFieldByAddress(self, address, feed=True):
     """
     Only search in existing fields
     """
     if feed and self._field_generator is not None:
         self._feedAll()
     if address < self._current_size:
         i = lowerBound(self._fields.values, lambda x: x.address + x.size <= address)
         if i is not None:
             return self._fields.values[i]
     return None
示例#4
0
 def getFieldByAddress(self, address, feed=True):
     """
     Only search in existing fields
     """
     if feed and self._field_generator is not None:
         self._feedAll()
     if address < self._current_size:
         i = lowerBound(self._fields.values,
                        lambda x: x.address + x.size <= address)
         if i is not None:
             return self._fields.values[i]
     return None