From c4dd7a1a684490673e25aaf4fabec5df138854c4 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Thu, 14 Mar 2013 05:42:27 +0000 Subject: Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2. --- ext/spl/examples/findfile.inc | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 ext/spl/examples/findfile.inc (limited to 'ext/spl/examples/findfile.inc') diff --git a/ext/spl/examples/findfile.inc b/ext/spl/examples/findfile.inc new file mode 100644 index 0000000..02ab792 --- /dev/null +++ b/ext/spl/examples/findfile.inc @@ -0,0 +1,65 @@ +file = $file; + $list = split(PATH_SEPARATOR, $path); + if (count($list) <= 1) { + parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path))); + } else { + $it = new AppendIterator(); + foreach($list as $path) { + $it->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path))); + } + parent::__construct($it); + } + } + + /** @return whether the current file matches the given filename + */ + function accept() + { + return !strcmp($this->current(), $this->file); + } + + /** @return the filename to search for. + * @note This may be overloaded and contain a regular expression for an + * extended class that uses regular expressions to search. + */ + function getSearch() + { + return $this->file; + } +} + +?> \ No newline at end of file -- cgit v1.2.1