From 6547e8921ac53f7d286906e9ff23e803f6e5ae84 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 26 May 2015 23:53:33 +0200 Subject: [PATCH] More usage of FileNotFoundException MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../input/text/class_FrameworkTextFileInputPointer.php | 7 +++++-- inc/classes/main/template/class_BaseTemplateEngine.php | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/inc/classes/main/file_directories/input/text/class_FrameworkTextFileInputPointer.php b/inc/classes/main/file_directories/input/text/class_FrameworkTextFileInputPointer.php index fa238a54..16e43d52 100644 --- a/inc/classes/main/file_directories/input/text/class_FrameworkTextFileInputPointer.php +++ b/inc/classes/main/file_directories/input/text/class_FrameworkTextFileInputPointer.php @@ -48,10 +48,13 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer { // No filename given throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); } elseif (!BaseFrameworkSystem::isReachableFilePath($fileName)) { - // File does not exist! + // File cannot be reached throw new FileIoException($fileName, self::EXCEPTION_FILE_NOT_REACHABLE); - } elseif (!BaseFrameworkSystem::isReadableFile($fileName)) { + } elseif ((!BaseFrameworkSystem::isReadableFile($fileName)) && (!file_exists($fileName))) { // File does not exist! + throw new FileNotFoundException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); + } elseif ((!BaseFrameworkSystem::isReadableFile($fileName)) && (file_exists($fileName))) { + // File cannot be read from (but exists) throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); } diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php index 68511ad1..69b86079 100644 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -662,7 +662,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @param $template The template we shall load * @param $extOther An other extension to use * @return void - * @throws FileIoException If the template was not found + * @throws FileNotFoundException If the template was not found */ protected function loadTemplate ($template, $extOther = '') { // Get extension for the template if empty @@ -712,7 +712,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $this->loadTemplate($template, $ext); } else { // Throw it again - throw new FileIoException($fqfn, self::EXCEPTION_FILE_NOT_FOUND); + throw new FileNotFoundException($fqfn, self::EXCEPTION_FILE_NOT_FOUND); } } -- 2.39.2