]> git.mxchange.org Git - core.git/blobdiff - inc/main/classes/file_directories/class_BaseFileIo.php
Debugging continued:
[core.git] / inc / main / classes / file_directories / class_BaseFileIo.php
index d52d02fa1b00c7e6d5ef8c9caa0d5eed68ef3967..829557eadb8866c1bbec63d7a25c068c46197da7 100644 (file)
@@ -1,10 +1,17 @@
 <?php
+// Own namespace
+namespace CoreFramework\FileSystem;
+
+// Import framework stuff
+use CoreFramework\Generic\NullPointerException;
+use CoreFramework\Object\BaseFrameworkSystem;
+
 /**
  * A general FileIo class
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -21,7 +28,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-class BaseFileIo extends BaseFrameworkSystem {
+class BaseFileIo extends BaseFrameworkSystem implements FilePointer, CloseableFile {
        /**
         * The current file we are working in
         */
@@ -67,9 +74,9 @@ class BaseFileIo extends BaseFrameworkSystem {
         * @throws      NullPointerException    If the file pointer instance is not set by setPointer()
         * @throws      InvalidResourceException        If there is being set
         */
-       private function closeFile () {
+       public function closeFile () {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: fileName=%s - CALLED!', __METHOD__, __LINE__, $this->getFileName()));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: fileName=%s - CALLED!', __METHOD__, __LINE__, $this->getFileName()));
 
                if (is_null($this->getPointer())) {
                        // Pointer not initialized
@@ -80,7 +87,7 @@ class BaseFileIo extends BaseFrameworkSystem {
                }
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: Closing file %s ...', __METHOD__, __LINE__, $this->getFileName()));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: Closing file %s ...', __METHOD__, __LINE__, $this->getFileName()));
 
                // Close the file pointer and reset the instance variable
                @fclose($this->getPointer());
@@ -88,7 +95,7 @@ class BaseFileIo extends BaseFrameworkSystem {
                $this->setFileName('');
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: EXIT!', __METHOD__, __LINE__));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: EXIT!', __METHOD__, __LINE__));
        }
 
        /**
@@ -160,7 +167,7 @@ class BaseFileIo extends BaseFrameworkSystem {
                $status = fseek($this->getPointer(), $offset, $whence);
 
                // Return status
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] status=%d', __METHOD__, __LINE__, $status));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] status=%d', __METHOD__, __LINE__, $status));
                return $status;
        }
 
@@ -171,14 +178,14 @@ class BaseFileIo extends BaseFrameworkSystem {
         * @todo        Handle seekStatus
         */
        public function size () {
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
 
                // Get current seek position
                $seekPosition = $this->determineSeekPosition();
 
                // Seek to end
                $seekStatus = $this->seek(0, SEEK_END);
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekStatus=%d', __METHOD__, __LINE__, $seekStatus));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] seekStatus=%d', __METHOD__, __LINE__, $seekStatus));
 
                // Get position again  (which is the end of the file)
                $size = $this->determineSeekPosition();
@@ -187,10 +194,8 @@ class BaseFileIo extends BaseFrameworkSystem {
                $this->seek($seekPosition);
 
                // Return size
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] size=%s - EXIT!', __METHOD__, __LINE__, $size));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] size=%s - EXIT!', __METHOD__, __LINE__, $size));
                return $size;
        }
-}
 
-// [EOF]
-?>
+}