+ buf = ''
+ for b in m.data():
+ if size == 0: break
+
+ # Skip over this data block if we can, based on remaining data
+ # offset and block size.
+ (bseg, boff, bcsum, bslice) = store.parse_ref(b)
+ if bslice is not None:
+ bsize = bslice[1]
+ if offset >= bsize:
+ offset -= bsize
+ continue
+
+ # Otherwise, load the data block and read any data out of it we
+ # can.
+ data = store.get(b)
+ if offset >= len(data):
+ offset -= len(data)
+ continue
+ if offset > 0:
+ data = data[offset:]
+ offset = 0
+ if size < len(data):
+ data = data[0:size]
+
+ buf += data
+ size -= len(data)
+
+ return buf