]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/file_directories/directory/class_FrameworkDirectoryPointer.php
Fixed some stuff + added debug lines.
[core.git] / inc / classes / main / file_directories / directory / class_FrameworkDirectoryPointer.php
index a267c63f075eb6d0f6174aa88bb5808754e32ee2..fc603ec341c8321c664a37884a42eeb1c33a117e 100644 (file)
@@ -105,11 +105,15 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
                // 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;
        }
 
@@ -119,22 +123,19 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
         * @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;
        }
 
@@ -150,7 +151,10 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
                        // 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;
@@ -167,12 +171,18 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
 
                        // 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;