cvs: php-src /ext/spl/examples findfile.inc findfile.php findregex.php

From: Date: Sun, 25 Jan 2004 13:03:26 +0000
Subject: cvs: php-src /ext/spl/examples findfile.inc findfile.php findregex.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-25847@lists.php.net to get a copy of this message
helly Sun Jan 25 08:03:26 2004 EDT Added files: /php-src/ext/spl/examples findfile.inc findregex.php Modified files: /php-src/ext/spl/examples findfile.php Log: Update examples http://cvs.php.net/diff.php/php-src/ext/spl/examples/findfile.php?r1=1.4&r2=1.5&ty=u Index: php-src/ext/spl/examples/findfile.php diff -u php-src/ext/spl/examples/findfile.php:1.4 php-src/ext/spl/examples/findfile.php:1.5 --- php-src/ext/spl/examples/findfile.php:1.4 Fri Jan 23 17:33:45 2004 +++ php-src/ext/spl/examples/findfile.php Sun Jan 25 08:03:24 2004 @@ -24,18 +24,5 @@ exit(1); } -class FindFile extends FilterIterator -{ - protected $file; - - function __construct($path, $file) { - $this->file = $file; - parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path))); - } - function accept() { - return !strcmp($this->current(), $this->file); - } -} - -foreach(new FindFile($argv[1], $argv[2]) as $pathname => $file) echo $file->getPathname()."\n"; +foreach(new FindFile($argv[1], $argv[2]) as $file) echo $file->getPathname()."\n"; ?> \ No newline at end of file http://cvs.php.net/co.php/php-src/ext/spl/examples/findfile.inc?r=1.1&p=1 Index: php-src/ext/spl/examples/findfile.inc +++ php-src/ext/spl/examples/findfile.inc <?php /** * @brief Base class to find files * @author Marcus Boerger * @version 1.0 * */ class FindFile extends FilterIterator { protected $file; function __construct($path, $file) { $this->file = $file; parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path))); } function accept() { return !strcmp($this->current(), $this->file); } } ?> http://cvs.php.net/co.php/php-src/ext/spl/examples/findregex.php?r=1.1&p=1 Index: php-src/ext/spl/examples/findregex.php +++ php-src/ext/spl/examples/findregex.php <?php /** Find a specific file by name. * * Usage: php findregex.php <path> <name> * * <path> Path to search in. * <name> Filename to look for. * * (c) Marcus Boerger, Adam Trachtenberg, 2004 */ if ($argc < 3) { echo <<<EOF Usage: php findregex.php <file> <name> Find a specific file by name. <path> Path to search in. <name> Regex for filenames to look for. EOF; exit(1); } class RegexFindFile extends FindFile { function accept() { return preg_match($this->file, $this->current()); } } foreach(new RegexFindFile($argv[1], $argv[2]) as $file) { echo $file->getPathname()."\n"; } ?>

« previous php.cvs (#25847) next »