Some fixes/improvements:
authorRoland Häder <roland@mxchange.org>
Wed, 30 May 2012 21:59:44 +0000 (21:59 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 30 May 2012 21:59:44 +0000 (21:59 +0000)
- Fixed bug in recursive directory scanning mechanism
- Added more debug lines
- Use NULL instead null to make Midnight Commander's CoolEdit happy! :-)

inc/classes/main/io/class_FrameworkDirectoryPointer.php

index 5a3cb5e..ba9b58c 100644 (file)
@@ -79,28 +79,28 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
                if (is_null($pathName)) {
                        // No pathname given
                        if ($inConstructor) {
-                               return null;
+                               return NULL;
                        } else {
                                throw new PathIsEmptyException(null, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                        }
                } elseif (!is_string($pathName)) {
                        // Is not a string
                        if ($inConstructor) {
-                               return null;
+                               return NULL;
                        } else {
                                throw new InvalidPathStringException(null, self::EXCEPTION_INVALID_STRING);
                        }
                } elseif (!is_dir($pathName)) {
                        // Not a directory
                        if ($inConstructor) {
-                               return null;
+                               return NULL;
                        } else {
                                throw new PathIsNoDirectoryException($pathName, self::EXCEPTION_INVALID_PATH_NAME);
                        }
                } elseif (!is_readable($pathName)) {
                        // Not readable
                        if ($inConstructor) {
-                               return null;
+                               return NULL;
                        } else {
                                throw new PathReadProtectedException($pathName, self::EXCEPTION_READ_PROTECED_PATH);
                        }
@@ -111,7 +111,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
                if (!is_resource($dirPointer)) {
                        // Something bad happend
                        if ($inConstructor) {
-                               return null;
+                               return NULL;
                        } else {
                                throw new DirPointerNotOpenedException($pathName, self::EXCEPTION_DIR_POINTER_INVALID);
                        }
@@ -148,26 +148,29 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
         * @return      string  Directory and/or file names read from the current
         *                                      directory pointer
         */
-       public function readDirectoryExcept ($except = '') {
-               if ((empty($except)) || (!is_array($except)) || (count($except) == 0)) {
+       public function readDirectoryExcept (array $except = array()) {
+               if (count($except) == 0) {
                        // No exception given, so read all data
                        return $this->readRawDirectory();
-               }
+               } // END - if
 
                // Read a raw line...
                $rawLine = $this->readRawDirectory();
 
                // Shall we exclude directories?
-               if ((!is_null($rawLine)) && ($rawLine !== false) && (in_array($rawLine, $except))) {
-                       // Exclude this part
-                       return $this->readDirectoryExcept($except);
-               } elseif ((!is_null($rawLine)) && ($rawLine !== false)) {
+               if ((!is_null($rawLine)) && ($rawLine !== false) && (!in_array($rawLine, $except))) {
                        // Return read data
+                       //* NOISY-DEBUG: */ $this->debugOutput('DIRECTORY: rawLine[' . gettype($rawLine) . ']=' . $rawLine);
                        return $rawLine;
+               } elseif ((!is_null($rawLine)) && ($rawLine !== false)) {
+                       // Exclude this part
+                       //* NOISY-DEBUG: */ $this->debugOutput('DIRECTORY: rawline[' . gettype($rawLine) . ']=' . $rawLine . ' - Recursive call!');
+                       return $this->readDirectoryExcept($except);
                }
 
                // End pointer reached
-               return null;
+               //* NOISY-DEBUG: */ $this->debugOutput('DIRECTORY: Returning NULL!');
+               return NULL;
        }
 
        /**