Example #1
0
 /**
  * Process the raw data from a binary stream
  * 
  * @param   Woops_Zip_Binary_Stream The binary stream
  * @return  void
  */
 public function processData(Woops_Zip_Binary_Stream $stream)
 {
     // Gets the CRC32
     $this->_crc32 = $stream->littleEndianUnsignedLong();
     // Checks if we have a signature for the data descriptor
     if ($this->_crc32 === 0x8074b50) {
         // Gets the CRC32
         $this->_crc32 = $stream->littleEndianUnsignedLong();
     }
     // Gets the compressed and uncompressed size
     $this->_compressedSize = $stream->littleEndianUnsignedLong();
     $this->_uncompressedSize = $stream->littleEndianUnsignedLong();
 }
Example #2
0
 /**
  * Class constructor
  * 
  * @param   resource    The file handle for which to create a binary stream
  * @param   boolean     Whether to close the file handle or not
  * @return  void
  * @see     Woops_Zip_Binary_Stream::__construct
  */
 public function __construct($handle, $closeHandle = true)
 {
     // Checks if the file exists
     if (!is_resource($handle)) {
         // Error - The file does not exist
         throw new Woops_Zip_Binary_File_Resource_Stream_Exception('Passed argument must be a valid file handle', Woops_Zip_Binary_File_Resource_Stream_Exception::EXCEPTION_NO_RESOURCE);
     }
     // Storage
     $data = '';
     // Reads until the end of the file handle
     while (!feof($handle)) {
         // Reads from the file handle
         $data .= fread($handle, 8192);
     }
     // Checks if we must close the file handle
     if ($closeHandle) {
         // Closes the file handle
         fclose($handle);
     }
     // Calls the parent constructor
     parent::__construct($data);
 }
Example #3
0
 /**
  * Process the raw data from a binary stream
  * 
  * @param   Woops_Zip_Binary_Stream The binary stream
  * @return  void
  */
 public function processData(Woops_Zip_Binary_Stream $stream)
 {
     // Resets the digital signature
     $this->_digitalSignature = NULL;
     // Signature of the central file headers
     $fileHeaderSignature = chr(0x50) . chr(0x4b) . chr(0x1) . chr(0x2);
     // Gets the central file header signature
     $signature = $stream->read(4);
     // Checks the central file header signature
     if ($signature !== $fileHeaderSignature) {
         // Error - Invalid central file header signature
         throw new Woops_Zip_Central_Directory_Exception('Invalid central file header signature', Woops_Zip_Central_Directory_Exception::EXCEPTION_BAD_FILE_HEADER_SIGNATURE);
     }
     // Processes the central file headers
     while ($signature === $fileHeaderSignature) {
         // Creates and stores the central file header object
         $fileHeader = new Woops_Zip_Central_File_Header();
         $this->_centralFileHeaders[] = $fileHeader;
         // Processes the central file header data
         $fileHeader->processData($stream);
         // Gets the next 4 bytes, to find an additionnal signature
         $signature = $stream->read(4);
     }
     // Checks for a digital signature
     if ($signature === chr(0x50) . chr(0x4b) . chr(0x5) . chr(0x5)) {
         // Creates the digital signature
         $this->_digitalSignature = new Woops_Zip_Digital_Signature();
         // Process the digital signature data
         $this->_digitalSignature->processData($stream);
         // Gets the next 4 bytes, to find an additionnal signature
         $signature = $stream->read(4);
     } else {
         // Rewinds the stream
         $stream->seek(-4, Woops_Zip_Binary_Stream::SEEK_CUR);
     }
 }
Example #4
0
 /**
  * Process the raw data from a binary stream
  * 
  * @param   Woops_Zip_Binary_Stream The binary stream
  * @return  void
  */
 public function processData(Woops_Zip_Binary_Stream $stream)
 {
     $length = $stream->littleEndianUnsignedShort();
     $this->_data = $stream->read($length);
 }
Example #5
0
 /**
  * Process the raw data from a binary stream
  * 
  * @param   Woops_Zip_Binary_Stream The binary stream
  * @return  void
  */
 public function processData(Woops_Zip_Binary_Stream $stream)
 {
     $this->_extractVersion = $stream->littleEndianUnsignedShort();
     $this->_flags = $stream->littleEndianUnsignedShort();
     $this->_compressionMethod = $stream->littleEndianUnsignedShort();
     $this->_mTime = $stream->littleEndianUnsignedShort();
     $this->_mDate = $stream->littleEndianUnsignedShort();
     $this->_crc32 = $stream->littleEndianUnsignedLong();
     $this->_compressedSize = $stream->littleEndianUnsignedLong();
     $this->_uncompressedSize = $stream->littleEndianUnsignedLong();
     $fileNameLength = $stream->littleEndianUnsignedShort();
     $extraFieldLength = $stream->littleEndianUnsignedShort();
     $this->_fileName = $stream->read($fileNameLength);
     $this->_processExtraField($stream, $extraFieldLength);
 }
Example #6
0
 /**
  * Process the raw data from a binary stream
  * 
  * @param   Woops_Zip_Binary_Stream The binary stream
  * @return  void
  */
 public function processData(Woops_Zip_Binary_Stream $stream)
 {
     $this->_madeByVersion = $stream->littleEndianUnsignedShort();
     $this->_extractVersion = $stream->littleEndianUnsignedShort();
     $this->_flags = $stream->littleEndianUnsignedShort();
     $this->_compressionMethod = $stream->littleEndianUnsignedShort();
     $this->_mTime = $stream->littleEndianUnsignedShort();
     $this->_mDate = $stream->littleEndianUnsignedShort();
     $this->_crc32 = $stream->littleEndianUnsignedLong();
     $this->_compressedSize = $stream->littleEndianUnsignedLong();
     $this->_uncompressedSize = $stream->littleEndianUnsignedLong();
     $fileNameLength = $stream->littleEndianUnsignedShort();
     $extraFieldLength = $stream->littleEndianUnsignedShort();
     $fileCommentLength = $stream->littleEndianUnsignedShort();
     $this->_diskNumberStart = $stream->littleEndianUnsignedShort();
     $this->_internalFileAttributes = $stream->littleEndianUnsignedShort();
     $this->_externalFileAttributes = $stream->littleEndianUnsignedLong();
     $this->_localHeaderOffset = $stream->littleEndianUnsignedLong();
     $this->_fileName = $stream->read($fileNameLength);
     $this->_processExtraField($stream, $extraFieldLength);
     $this->_fileComment = $stream->read($fileCommentLength);
 }