*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Can the next entry be read?
assert($this->getDirectoryIteratorInstance()->valid());
- // Default is FALSE
- $currentEntry = FALSE;
-
// Read data from the directory pointer and return it
$currentEntry = $this->getDirectoryIteratorInstance()->current();
return $this->readRawDirectory();
} elseif (!$this->getDirectoryIteratorInstance()->valid()) {
// No more left to read
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: EOD reached.');
return NULL;
}
if (is_object($currentEntry)) {
// Get file name
$rawLine = $currentEntry->getFilename();
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine . ',isDot=' . intval($this->getDirectoryIteratorInstance()->isDot()));
- // Is it not excluded?
- if (in_array($rawLine, $except)) {
+ // Is it a dot-directory or excluded?
+ if (($this->getDirectoryIteratorInstance()->isDot()) || (in_array($rawLine, $except))) {
// To next entry
$this->getDirectoryIteratorInstance()->next();
*/
public function closeDirectory () {
// Close the directory by unsetting it
- $this->setDirectoryIteratorInstance(NULL);
+ $this->unsetDirectoryIteratorInstance();
$this->setPathName('');
}
/**
* Setter for the directory pointer
*
- * @param $iteratorInstance An instanceof a DirectoryIterator class or NULL to unset ("close") it.
+ * @param $iteratorInstance An instanceof a DirectoryIterator class
* @return void
*/
- protected final function setDirectoryIteratorInstance (DirectoryIterator $iteratorInstance = NULL) {
- // Set instance (or NULL)
+ protected final function setDirectoryIteratorInstance (DirectoryIterator $iteratorInstance) {
+ // Set instance
$this->iteratorInstance = $iteratorInstance;
}
return $this->iteratorInstance;
}
+ /**
+ * Remove directory iterator instance (effectively closing it) by setting
+ * it to NULL. This will trigger a call on the destructor which will then
+ * "close" the iterator.
+ *
+ * @param $iteratorInstance An instanceof a DirectoryIterator class
+ * @return void
+ */
+ protected final function unsetDirectoryIteratorInstance () {
+ // "Unset" the instance
+ $this->iteratorInstance = NULL;
+ }
+
/**
* Setter for path name
*