More usage of FileNotFoundException
[core.git] / inc / classes / main / file_directories / input / text / class_FrameworkTextFileInputPointer.php
index 5338fe32e55c02a339159df0975853c151e4a91e..16e43d52b7ea934d434b36acccc637413dca7778 100644 (file)
@@ -37,8 +37,9 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
         * be verified here.
         *
         * @param       $fileName       The file name we shall pass to fopen()
-        * @throws      FileIsEmptyException    If the provided file name is empty.
-        * @throws      FileIoException                 If fopen() returns not a file resource
+        * @throws      FileIsEmptyException            If the provided file name is empty.
+        * @throws      FileIoException                         If the file is not reachable
+        * @throws      FileReadProtectedException      If the file cannot be read from
         * @return      void
         */
        public static final function createFrameworkTextFileInputPointer ($fileName) {
@@ -46,11 +47,14 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
                if ((is_null($fileName)) || (empty($fileName))) {
                        // No filename given
                        throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!file_exists($fileName)) {
-                       // File does not exist!
-                       throw new FileIoException($fileName, self::EXCEPTION_FILE_NOT_FOUND);
-               } elseif (!is_readable($fileName)) {
+               } elseif (!BaseFrameworkSystem::isReachableFilePath($fileName)) {
+                       // File cannot be reached
+                       throw new FileIoException($fileName, self::EXCEPTION_FILE_NOT_REACHABLE);
+               } 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);
                }