I am playing around with php rar
http://www.php.net/manual/en/intro.rar.php
Goal : Gather file (name) information of multi volume rar archives, from only the first volume.
Example :
Complete volume : testArchive.rar , testArchive.r00
Available : testArchive.rar
Scan files inside archive from testArchive.rar WITHOUT testArchive.r00
Winrar ( rarlabs.com ) gives you the archived (file) content of the multi volume rar archive from the first volume.
Now I want this accomplished by php.
I tried the following but this gives me an empty array.
function retnull() { return null; }
$arch = RarArchive::open("testArchive.rar" , NULL , 'retnull' );
$arch->setAllowBroken(true);
if ($arch === FALSE)
die("Cannot open testArchive.rar");
$entries = $arch->getEntries();
if ($entries === FALSE)
die("Cannot retrieve entries");
echo '<pre>';
print_r($entries);
echo '</pre>';
I do not need to extract the rar files , but only need the content [NAMES] of the folders/files inside the archive like the program winrar does.
Can somebody give me a hint in the right direction ?
Found a solution to my own problem.
Install UnRar http://www.win-rar.com/rarextras.html
( I am using CentOS : yum install unrar )
<?php
$path ='/path/to/archiveFolder/';
$archive='testArchive.rar';
$var =exec('unrar l -p- '.escapeshellarg($path.$archive),$file_output);
echo '<pre>';
print_r($file_output);
echo '</pre>';
?>
This will give you the following output:
Array
(
[0] =>
[1] => UNRAR 4.10 freeware Copyright (c) 1993-2012 Alexander Roshal
[2] =>
[3] => Volume path/to/archiveFolder/testArchive.rar
[4] =>
[5] => Name Size Packed Ratio Date Time Attr CRC Meth Ver
[6] => -------------------------------------------------------------------------------
[7] => testfile.mkv 1699997366 49999891 --> 19-02-12 21:05 .....A. 95E20DA9 m0g 2.0
[8] => -------------------------------------------------------------------------------
[9] => 1 1699997366 49999891 2% volume 1
[10] =>
)
After that just write a class to retrieve the information you need with reg-patterns or substr.