Esempio n. 1
0
 /**
  * Process the raw data from a binary stream
  * 
  * @param   Woops_Gzip_Binary_Stream    The binary stream
  * @return  void
  */
 public function processData(Woops_Gzip_Binary_Stream $stream)
 {
     // Gets the member signature
     $signature = $stream->littleEndianUnsignedShort();
     // Checks the member signature
     if ($signature !== 0x8b1f) {
         // Error - Invalid member signature
         throw new Woops_Gzip_Member_Exception('Invalid member signature (' . $signature . ')', Woops_Gzip_Member_Exception::EXCEPTION_BAD_SIGNATURE);
     }
     // Gets the compression method
     $this->_compressionMethod = $stream->unsignedChar();
     // Checks the compression method
     if ($this->_compressionMethod !== self::COMPRESSION_DEFLATE) {
         // Error - Invalid compression method
         throw new Woops_Gzip_Member_Exception('Invalid compression method (' . $this->_compressionMethod . ')', Woops_Gzip_Member_Exception::EXCEPTION_BAD_COMPRESSION_METHOD);
     }
     // Gets the flags
     $flags = $stream->unsignedChar();
     // Gets the modification time
     $this->_mTime = $stream->littleEndianUnsignedLong();
     // Gets the extra flags
     $extraFlags = $stream->unsignedChar();
     // Gets the operating system
     $this->_os = $stream->unsignedChar();
     // Checks for an extra field
     if ($flags & self::FLAG_EXTRA) {
         // Gets the extra field type
         $type = $stream->littleEndianUnsignedShort();
         // Checks if the type is known
         if (isset(self::$_extraFields[$type])) {
             // Gets the field class
             $fieldClass = self::$_extraFields[$type];
             // Creates the extra field
             $this->_extraField = new $fieldClass();
         } else {
             // Unknown extra field
             $this->_extraField = new Woops_Gzip_UnknownExtraField($type);
         }
         // Process the extra field data
         $this->_extraField->processData($stream);
     }
     // Checks for a file name
     if ($flags & self::FLAG_NAME) {
         // Gets the file name
         $this->_fileName = $stream->nullTerminatedString();
     }
     // Checks for a file comment
     if ($flags & self::FLAG_COMMENT) {
         // Gets the file comment
         $this->_fileComment = $stream->nullTerminatedString();
     }
     // Checks for a CRC16
     if ($flags & self::FLAG_HRCR) {
         // Gets the CRC16
         $crc16 = $stream->littleEndianUnsignedShort();
     }
 }