public function __construct(BinaryStreamParser $parser) { $parser->readBytes(44); $numDeps = $parser->readByte(); $parser->readBytes(3); while ($numDeps > 0) { while ($parser->readByte() !== 0) { } $numDeps--; } $numAttribs = $parser->readUInt32(); $attribs = array(); while ($numAttribs > 0) { $keyLen = $parser->readUInt16(); $key = $parser->readBytes($keyLen); $locale = hex2bin(dechex($parser->readUInt32())); $valueLen = $parser->readUInt16(); $value = $parser->readBytes($valueLen); $attribs[$key][$locale] = $value; $numAttribs--; } if (isset($attribs['DocInfo/Name'])) { $this->name = $attribs['DocInfo/Name']; } if (isset($attribs['DocInfo/DescShort'])) { $this->shortDescription = $attribs['DocInfo/DescShort']; } if (isset($attribs['DocInfo/DescLong'])) { $this->longDescription = $attribs['DocInfo/DescLong']; } }
public function __construct(Stream $stream) { $stream = new BinaryStreamParser($stream); $this->source = $stream->readByte(); $this->namespace = $stream->readUInt32(); $count = $stream->readUInt32(); for ($i = 0; $i < $count; $i++) { $namespace = $stream->readUInt32(); $attrid = $stream->readUInt32(); $scope = $stream->readByte(); $value = trim(strrev($stream->readBytes(4))); if (!isset($this->attributes[$scope])) { $this->attributes[$scope] = array(); } $this->attributes[$scope][$attrid] = new Attribute($attrid, $namespace, $scope, $value); } }
private function parseSignature(BinaryStreamParser $parser) { $signature = chr($parser->readByte()); $signature .= chr($parser->readByte()); $signature .= chr($parser->readByte()); $signature .= $parser->readByte(); return $signature; }
private function createCompressedStream(Sector $sector) { $stream = $this->stream; if ($this->block->isCompressed() && $this->block->getSize() > $this->block->getCompressedSize()) { $parser = new BinaryStreamParser($this->stream); $compressionType = $parser->readByte(); switch ($compressionType) { case 0x0: return $stream; case 0x2: $len = $parser->readUInt16(); $blockData = $stream->readBytes($len); return new MemoryStream(gzinflate($blockData)); // case 0x02: return new CompressedStream($stream, new DeflateCompression()); // case 0x02: return new CompressedStream($stream, new DeflateCompression()); case 0x10: return new CompressedStream($stream, new BZIPCompression()); default: throw new CompressionException(sprintf('Invalid compression format: %s', $compressionType)); } } return $stream; }