From: Roland Häder Date: Tue, 14 Nov 2017 21:19:37 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=0602f1ce534b364bda168985181e5882bb6e5fd7 Continued: - need to return full SplFileInfo instance instead of file name - it is a better OOD anyway Signed-off-by: Roland Häder --- diff --git a/framework/config/config-local.php-dist b/framework/config/config-local.php-dist index d6bd7c1d..401e2c1d 100644 --- a/framework/config/config-local.php-dist +++ b/framework/config/config-local.php-dist @@ -1,4 +1,7 @@ setConfigEntry('foo_bar', 12345); diff --git a/framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php b/framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php index eba7d423..4c033024 100644 --- a/framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php +++ b/framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php @@ -133,7 +133,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Framework * Read lines from the current directory pointer except some parts * * @param $except Some parts of a directory we want to ignore. Valid: directory and file names, other values will be silently ignored - * @return string Directory and/or file names read from the current directory pointer + * @return SplFileInfo An instance of a SplFileInfo class */ public function readDirectoryExcept (array $except = array()) { // No exceptions given? @@ -148,7 +148,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Framework } // Init raw line - $rawLine = NULL; + $fileInfoInstance = NULL; // Read a raw line... $currentEntry = $this->readRawDirectory(); @@ -157,17 +157,17 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Framework // Shall we exclude directories? if (is_object($currentEntry)) { // Get file name - $rawLine = $currentEntry->getFilename(); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine . ',isDot=' . intval($this->getDirectoryIteratorInstance()->isDot())); + $fileInfoInstance = $currentEntry; + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: fileInfoInstance[' . gettype($fileInfoInstance) . ']=' . $fileInfoInstance . ',isDot=' . intval($this->getDirectoryIteratorInstance()->isDot())); // Is it a dot-directory or excluded? - if (($this->getDirectoryIteratorInstance()->isDot()) || (in_array($rawLine, $except))) { + if (($this->getDirectoryIteratorInstance()->isDot()) || (in_array($fileInfoInstance, $except))) { // To next entry $this->getDirectoryIteratorInstance()->next(); // Exclude this part - $rawLine = $this->readDirectoryExcept($except); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawline[' . gettype($rawLine) . ']=' . $rawLine . ' - Recursive call!'); + $fileInfoInstance = $this->readDirectoryExcept($except); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: fileInfoInstance[' . gettype($fileInfoInstance) . ']=' . $fileInfoInstance . ' - Recursive call!'); } // END - if } // END - if @@ -175,8 +175,8 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Framework $this->getDirectoryIteratorInstance()->next(); // Return read line - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine); - return $rawLine; + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: fileInfoInstance[' . gettype($fileInfoInstance) . ']=' . $fileInfoInstance); + return $fileInfoInstance; } /** diff --git a/framework/main/interfaces/io/directory/class_FrameworkDirectory.php b/framework/main/interfaces/io/directory/class_FrameworkDirectory.php index 6b270bd7..a87ba801 100644 --- a/framework/main/interfaces/io/directory/class_FrameworkDirectory.php +++ b/framework/main/interfaces/io/directory/class_FrameworkDirectory.php @@ -39,7 +39,7 @@ interface FrameworkDirectory extends FrameworkInterface { * Read lines from the current directory pointer except some parts * * @param $except Some parts of a directory we want to ignore. Valid: directory and file names, other values will be silently ignored - * @return string Directory and/or file names read from the current directory pointer + * @return SplFileInfo An instance of a SplFileInfo class */ function readDirectoryExcept (array $except = array());