// Get an iterator for the directory
$directoryInstance = new DirectoryIterator($pathName);
+ // ... and rewind back
+ $directoryInstance->rewind();
+
// Set directory pointer and path name
$pointerInstance->setDirectoryInstance($directoryInstance);
$pointerInstance->setPathName($pathName);
// Return the instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: Opened pathName=' . $pathName . ' - EXIT!');
return $pointerInstance;
}
* @return $currentEntry Current entry from encapsulated iterator
*/
public function readRawDirectory () {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . '] - CALLED!');
+
// Can the next entry be read?
assert($this->getDirectoryInstance()->valid());
// Default is FALSE
$currentEntry = FALSE;
- // Is it a dot directory?
- if (!$this->getDirectoryInstance()->isDot()) {
- // Read data from the directory pointer and return it
- $currentEntry = $this->getDirectoryInstance()->current();
- } // END - if
-
- // Advance to next entry
- $this->getDirectoryInstance()->next();
+ // Read data from the directory pointer and return it
+ $currentEntry = $this->getDirectoryInstance()->current();
// Return found entry
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: currentEntry[]=' . gettype($currentEntry) . ' - EXIT!');
return $currentEntry;
}
// No exception given, so read all files and directories, but not recursive
self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: No exceptions given, please use readRawDirectory() instead!');
return $this->readRawDirectory();
- } // END - if
+ } elseif (!$this->getDirectoryInstance()->valid()) {
+ // No more left to read
+ return NULL;
+ }
// Init raw line
$rawLine = NULL;
// Is it not excluded?
if (in_array($rawLine, $except)) {
+ // To next entry
+ $this->getDirectoryInstance()->next();
+
// Exclude this part
$rawLine = $this->readDirectoryExcept($except);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawline[' . gettype($rawLine) . ']=' . $rawLine . ' - Recursive call!');
} // END - if
} // END - if
+ // To next entry
+ $this->getDirectoryInstance()->next();
+
// Return read line
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine);
return $rawLine;