]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php
Continued:
[core.git] / framework / main / classes / file_directories / io / class_FrameworkFileInputOutputPointer.php
index c9c9ca54d651dec37d275715684cbc8c29253fec..b67025c31edb4c1698780a53df33743119266ee2 100644 (file)
@@ -1,16 +1,16 @@
 <?php
 // Own namespace
-namespace CoreFramework\Filesystem\Pointer;
+namespace Org\Mxchange\CoreFramework\Filesystem\Pointer;
 
 // Import framework stuff
-use CoreFramework\Bootstrap\FrameworkBootstrap;
-use CoreFramework\FileSystem\BaseFileIo;
-use CoreFramework\FileSystem\FileReadProtectedException;
-use CoreFramework\FileSystem\FileWriteProtectedException;
-use CoreFramework\Filesystem\PathWriteProtectedException;
-use CoreFramework\Generic\NullPointerException;
-use CoreFramework\Generic\UnsupportedOperationException;
-use CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\FileSystem\BaseFileIo;
+use Org\Mxchange\CoreFramework\FileSystem\FileReadProtectedException;
+use Org\Mxchange\CoreFramework\FileSystem\FileWriteProtectedException;
+use Org\Mxchange\CoreFramework\Filesystem\PathWriteProtectedException;
+use Org\Mxchange\CoreFramework\Generic\NullPointerException;
+use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
+use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 
 // Import SPL stuff
 use \SplFileInfo;
@@ -20,7 +20,7 @@ use \SplFileInfo;
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -67,12 +67,12 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                } elseif ((!FrameworkBootstrap::isReadableFile($fileInstance)) && (file_exists($fileInstance))) {
                        // File exists but cannot be read
                        throw new FileReadProtectedException($fileInstance, self::EXCEPTION_FILE_CANNOT_BE_READ);
-               } elseif (($fileInstance->isFile()) && (!$fileInstance->isWritable())) {
-                       // File exists but cannot be written
-                       throw new FileWriteProtectedException($fileInstance, self::EXCEPTION_FILE_CANNOT_BE_WRITTEN);
                } elseif (!is_writable($fileInstance->getPath())) {
                        // Path is not writable
                        throw new PathWriteProtectedException($fileInstance, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN);
+               } elseif (($fileInstance->isFile()) && (!$fileInstance->isWritable())) {
+                       // File exists but cannot be written
+                       throw new FileWriteProtectedException($fileInstance, self::EXCEPTION_FILE_CANNOT_BE_WRITTEN);
                }
 
                // Try to open a handler
@@ -102,7 +102,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         *
         * @return      void
         * @throws      NullPointerException    If the file pointer instance
-        *                                                                      is not set by setPointer()
+        *                                                                      is not set by setFileObject()
         * @todo Add more checks
         */
        private function validateFilePointer () {
@@ -133,7 +133,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         * @param       $dataStream             The data stream we shall write to the file
         * @return      mixed                   Number of writes bytes or false on error
         */
-       public function writeToFile ($dataStream) {
+       public function writeToFile (string $dataStream) {
                // Validate the pointer
                $this->validateFilePointer();
 
@@ -148,7 +148,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         * @param       $data                   Data to be written
         * @return      mixed                   Number of writes bytes or false on error
         */
-       public function writeAtPosition ($seekPosition, $data) {
+       public function writeAtPosition (int $seekPosition, string $data) {
                // First seek to it
                $this->seek($seekPosition);
 
@@ -200,7 +200,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         * @param       $bytes  Amount of bytes to read
         * @return      $data   Data read from file
         */
-       public function read ($bytes = NULL) {
+       public function read (int $bytes = NULL) {
                // Validate the pointer
                $this->validateFilePointer();