| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* Show a progress bar when parsing a directory from CLI
|
|
|
4 |
* Do not display any progress bar from other SAPI
|
|
|
5 |
*
|
|
|
6 |
* To run on Windows platform, do:
|
|
|
7 |
* (path to PHP cli)\php.exe -f (this script)
|
|
|
8 |
*
|
|
|
9 |
* PHP versions 4 and 5
|
|
|
10 |
*
|
|
|
11 |
* @category PHP
|
|
|
12 |
* @package PHP_CompatInfo
|
|
|
13 |
* @author Laurent Laville <pear@laurent-laville.org>
|
|
|
14 |
* @license http://www.opensource.org/licenses/bsd-license.php BSD
|
|
|
15 |
* @version CVS: $Id: parseDir_withCustomProgressBar.php,v 1.4 2008/07/24 21:18:08 farell Exp $
|
|
|
16 |
* @link http://pear.php.net/package/PHP_CompatInfo
|
|
|
17 |
* @ignore
|
|
|
18 |
*/
|
|
|
19 |
require_once 'PHP/CompatInfo.php';
|
|
|
20 |
|
|
|
21 |
if (php_sapi_name() == 'cli') {
|
|
|
22 |
/*
|
|
|
23 |
Display a progress bar like this one:
|
|
|
24 |
|
|
|
25 |
[))))) ] 8% - 45/563 files
|
|
|
26 |
|
|
|
27 |
*/
|
|
|
28 |
$pbar = array('formatString' => '[%bar%] %percent% - %fraction% files',
|
|
|
29 |
'barfill' => ')',
|
|
|
30 |
'prefill' => ' ',
|
|
|
31 |
'options' => array('percent_precision' => 0));
|
|
|
32 |
|
|
|
33 |
$driverType = 'text';
|
|
|
34 |
$driverOptions = array('silent' => false, 'progress' => 'bar',
|
|
|
35 |
'progressbar' => $pbar);
|
|
|
36 |
|
|
|
37 |
} else {
|
|
|
38 |
$driverType = 'array';
|
|
|
39 |
$driverOptions = array();
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
$info = new PHP_CompatInfo($driverType, $driverOptions);
|
|
|
43 |
$dir = 'C:\php\pear\HTML_Progress2';
|
|
|
44 |
$r = $info->parseDir($dir);
|
|
|
45 |
/*
|
|
|
46 |
To keep backward compatibility, result is also return (here in $r)
|
|
|
47 |
but you don't need to print it, it's the default behavior of API 1.8.0
|
|
|
48 |
*/
|
|
|
49 |
//var_export($r);
|
|
|
50 |
?>
|