mirror of
https://github.com/php-win-ext/php-rar.git
synced 2026-04-24 04:48:05 +02:00
9a7227a9e0
- RAR navigation and indexing were moved to rar_navigation.c. - RAR archives that contain entries with the same name are correctly handled. - Changed the way properties are accessed in RarEntry (does not require building the properties table in trunk). - Fixed memory leak in silent url stat. - Fixed handling of optional passwords. Now giving no password, NULL or '' result in the same behavior. git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@299926 c90b9560-bf6c-de11-be94-00142212c4b1
43 lines
945 B
PHP
43 lines
945 B
PHP
--TEST--
|
|
RarEntry::getStream() function (good RAR file, several volumes)
|
|
--SKIPIF--
|
|
<?php if(!extension_loaded("rar")) print "skip"; ?>
|
|
--FILE--
|
|
<?php
|
|
|
|
$rar_file1 = rar_open(dirname(__FILE__).'/multi.part1.rar');
|
|
$entries = rar_list($rar_file1);
|
|
echo count($entries)." files:\n\n";
|
|
//var_dump($entries);
|
|
function int32_to_hex($value) {
|
|
$value &= 0xffffffff;
|
|
return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT);
|
|
}
|
|
foreach ($entries as $e) {
|
|
$stream = $e->getStream();
|
|
if ($stream === false) {
|
|
die("Failed to get stream.\n");
|
|
break;
|
|
}
|
|
echo $e->getName().": ";
|
|
$a = "";
|
|
while (!feof($stream)) {
|
|
$a .= fread($stream, 8192);
|
|
}
|
|
echo strlen($a)." bytes, CRC ";
|
|
echo int32_to_hex(crc32($a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc()
|
|
}
|
|
|
|
echo "Done\n";
|
|
?>
|
|
--EXPECTF--
|
|
3 files:
|
|
|
|
file1.txt: 18 bytes, CRC 52B28202
|
|
|
|
file2.txt: 17704 bytes, CRC F2C79881
|
|
|
|
file3.txt: 18 bytes, CRC BCBCE32E
|
|
|
|
Done
|