From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- includes/libs/RiffExtractor.php | 100 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 includes/libs/RiffExtractor.php (limited to 'includes/libs/RiffExtractor.php') diff --git a/includes/libs/RiffExtractor.php b/includes/libs/RiffExtractor.php new file mode 100644 index 00000000..f987c59d --- /dev/null +++ b/includes/libs/RiffExtractor.php @@ -0,0 +1,100 @@ + self::extractUInt32( $fileSize ), + 'fourCC' => $fourCC, + 'chunks' => array(), + ); + $numberOfChunks = 0; + + // Find out the chunks + while ( !feof( $file ) && !( $numberOfChunks >= $maxChunks && $maxChunks >= 0 ) ) { + $chunkStart = ftell( $file ); + + $chunkFourCC = fread( $file, 4 ); + if ( !$chunkFourCC || strlen( $chunkFourCC ) != 4 ) { + return $info; + } + + $chunkSize = fread( $file, 4 ); + if ( !$chunkSize || strlen( $chunkSize ) != 4 ) { + return $info; + } + $intChunkSize = self::extractUInt32( $chunkSize ); + + // Add chunk info to the info structure + $info['chunks'][] = array( + 'fourCC' => $chunkFourCC, + 'start' => $chunkStart, + 'size' => $intChunkSize + ); + + // Uneven chunks have padding bytes + $padding = $intChunkSize % 2; + // Seek to the next chunk + fseek( $file, $intChunkSize + $padding, SEEK_CUR ); + + } + + return $info; + } + + /** + * Extract a little-endian uint32 from a 4 byte string + * @param string $string 4-byte string + * @return int + */ + public static function extractUInt32( $string ) { + $unpacked = unpack( 'V', $string ); + return $unpacked[1]; + } +}; -- cgit v1.2.2