def decompress(self): """Handle decompressing data if necessary""" indata = self.data if self.compress == COMPRESS_LZ4: data = tools.Decompress(indata, 'lz4') elif self.compress == COMPRESS_LZMA: data = tools.Decompress(indata, 'lzma') else: data = indata self.memlen = len(data) self.data = data self.data_len = len(indata)
def ReadData(self, decomp=True): indata = Entry.ReadData(self, decomp) if decomp: data = tools.Decompress(indata, self.compress) if self.uncomp_size: tout.Info( "%s: Decompressing data size %#x with algo '%s' to data size %#x" % (self.GetPath(), len(indata), self.compress, len(data))) else: data = indata return data
def ReadChildData(self, child, decomp=True): tout.Debug("ReadChildData for child '%s'" % child.GetPath()) parent_data = self.ReadData(True) offset = child.offset - self._skip_at_start tout.Debug("Extract for child '%s': offset %#x, skip_at_start %#x, result %#x" % (child.GetPath(), child.offset, self._skip_at_start, offset)) data = parent_data[offset:offset + child.size] if decomp: indata = data data = tools.Decompress(indata, child.compress) if child.uncomp_size: tout.Info("%s: Decompressing data size %#x with algo '%s' to data size %#x" % (child.GetPath(), len(indata), child.compress, len(data))) return data
def ReadChildData(self, child, decomp=True): """Read the data for a particular child entry Args: child: Child entry to read data for decomp: True to return uncompressed data, False to leave the data compressed if it is compressed Returns: Data contents of entry """ parent_data = self.ReadData(True) data = parent_data[child.offset:child.offset + child.size] if decomp: indata = data data = tools.Decompress(indata, child.compress) if child.uncomp_size: tout.Info( "%s: Decompressing data size %#x with algo '%s' to data size %#x" % (child.GetPath(), len(indata), child.compress, len(data))) return data