Location: PHPKode > scripts > Simple Object > DirectoryIterator.php
<?php
	class DirectoryIterator extends SimpleIterator {
		
		var $dir_path;
		var $dir_handle;
		
		function DirectoryIterator($dir_path) {
			parent::SimpleIterator(SO_STRICT);
			$this->init('name');
			$this->dir_handle = opendir($this->dir_path);
		}
		
		function next() {
			$elem_name = readdir($this->dir_handle);
			if ( $elem_name !== FALSE ) {
				$this->set('name',$elem_name);
				return TRUE;
			} else {
				return FALSE;
			}
		}
		
		function reset() {
			rewind($this->dir_handle);
		}
		
		function size() {
			$this->reset();
			$size = 0;
			while ( $this->next() ) {
				$size++;
			}
			return $size;
		}
	}
?>
Return current item: Simple Object