]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/file_directories/directory/class_FrameworkDirectoryPointer.php
Opps, forgot this.
[core.git] / inc / classes / main / file_directories / directory / class_FrameworkDirectoryPointer.php
index 2d075cbdd8f4ec2747fceed5c23ad0c758763672..b855a62c52e820f63f4b6806f4a3c92d22c3582a 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @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
  *
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Directory {
+class FrameworkDirectoryPointer extends BaseFrameworkSystem implements FrameworkDirectory {
        /**
         * The current path we are working in
         */
@@ -128,9 +128,6 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Directory
                // 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();
 
@@ -153,6 +150,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Directory
                        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;
                }
 
@@ -167,10 +165,10 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Directory
                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();
 
@@ -196,18 +194,18 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Directory
         */
        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;
        }
 
@@ -220,6 +218,19 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Directory
                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
         *