The type of fixture to generate: rar, srr, par2, zip (default is all) * -r Regenerate existing fixture files (default is to create only missing ones) * -p Run in pretend mode, output debug info without making changes */ error_reporting(E_ALL | E_STRICT); ini_set('display_startup_errors', 'on'); ini_set('display_errors', 'on'); $opts = getopt('prt:'); $pretend = isset($opts['p']) ? true : false; $refresh = isset($opts['r']) ? true : false; if ($pretend) {echo "*** Running in pretend mode ***\n";} if (!isset($opts['t']) || $opts['t'] == 'rar') makeRarFixtures($pretend, $refresh); if (!isset($opts['t']) || $opts['t'] == 'srr') makeSrrFixtures($pretend, $refresh); if (!isset($opts['t']) || $opts['t'] == 'par2') makePar2Fixtures($pretend, $refresh); if (!isset($opts['t']) || $opts['t'] == 'zip') makeZipFixtures($pretend, $refresh); if (!isset($opts['t']) || $opts['t'] == 'szip') makeSzipFixtures($pretend, $refresh); /** * Generates test fixtures from RAR sample files. * * @param boolean $pretend debug output only? * @param boolean $refresh regenerate existing files? * @return void */ function makeRarFixtures($pretend=false, $refresh=true) { require_once dirname(__FILE__).'/../../rarinfo.php'; $rar = new RarInfo; foreach(glob(dirname(__FILE__).'/rar/*.rar') as $rarfile) { $fname = pathinfo($rarfile, PATHINFO_BASENAME).'.blocks'; $file = dirname(__FILE__)."/rar/$fname"; if (!$refresh && file_exists($file)) {continue;} echo "Generating for $rarfile:\n"; $rar->open($rarfile, true); if ($rar->error) { echo "Error: {$rar->error}\n"; continue; } $data = $rar->getBlocks(); if (!$pretend) { $data = "open($srrfile); if ($srr->error) { echo "Error: {$srr->error}\n"; continue; } $data = $srr->getBlocks(); if (!$pretend) { $data = "open($par2file); if ($par2->error) { echo "Error: {$par2->error}\n"; continue; } $data = $par2->getPackets(true); if (!$pretend) { $data = "open($zipfile); if ($zip->error) { echo "Error: {$zip->error}\n"; continue; } $data = $zip->getRecords(); if (!$pretend) { $data = "open($szipfile, true); if ($szip->error) { echo "Error: {$szip->error}\n"; continue; } $data = $szip->getHeaders(); if (!$pretend) { $data = "