From 39e4999ebb90e7ecdf1c5862300573b297698f58 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 27 Aug 2015 03:36:26 +0200 Subject: [PATCH] Added new classes for file system and interfaces for it + introduced CloseableFile. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../class_BaseAbstractFile.php | 4 +- .../file_directories/class_BaseFileIo.php | 4 +- inc/main/classes/filesystem/.htaccess | 1 + inc/main/classes/filesystem/class_ | 51 +++++++++++++++++++ .../filesystem/class_BaseFilesystem.php | 39 ++++++++++++++ inc/main/interfaces/filesystem/.htaccess | 1 + .../filesystem/class_Filesystem.php | 28 ++++++++++ .../interfaces/io/class_CloseableFile.php | 37 ++++++++++++++ 8 files changed, 161 insertions(+), 4 deletions(-) create mode 100644 inc/main/classes/filesystem/.htaccess create mode 100644 inc/main/classes/filesystem/class_ create mode 100644 inc/main/classes/filesystem/class_BaseFilesystem.php create mode 100644 inc/main/interfaces/filesystem/.htaccess create mode 100644 inc/main/interfaces/filesystem/class_Filesystem.php create mode 100644 inc/main/interfaces/io/class_CloseableFile.php diff --git a/inc/main/classes/file_directories/class_BaseAbstractFile.php b/inc/main/classes/file_directories/class_BaseAbstractFile.php index e26c58bb..862c725c 100644 --- a/inc/main/classes/file_directories/class_BaseAbstractFile.php +++ b/inc/main/classes/file_directories/class_BaseAbstractFile.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseAbstractFile extends BaseFrameworkSystem { +class BaseAbstractFile extends BaseFrameworkSystem implements FilePointer, CloseableFile { /** * Counter for total entries */ @@ -133,7 +133,7 @@ class BaseAbstractFile extends BaseFrameworkSystem { * * @return void */ - private function closeFile () { + public function closeFile () { // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: fileName=%s - CALLED!', __METHOD__, __LINE__, $this->getFileName())); diff --git a/inc/main/classes/file_directories/class_BaseFileIo.php b/inc/main/classes/file_directories/class_BaseFileIo.php index d52d02fa..2f9b6f8d 100644 --- a/inc/main/classes/file_directories/class_BaseFileIo.php +++ b/inc/main/classes/file_directories/class_BaseFileIo.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseFileIo extends BaseFrameworkSystem { +class BaseFileIo extends BaseFrameworkSystem implements FilePointer, CloseableFile { /** * The current file we are working in */ @@ -67,7 +67,7 @@ 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())); diff --git a/inc/main/classes/filesystem/.htaccess b/inc/main/classes/filesystem/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filesystem/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filesystem/class_ b/inc/main/classes/filesystem/class_ new file mode 100644 index 00000000..5a726780 --- /dev/null +++ b/inc/main/classes/filesystem/class_ @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Filesystem extends BaseFilesystem implements Filesystem { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this Filesystem class and prepares it for usage + * + * @param $appInstance A manageable application + * @return $///Instance An instance of this Filesystem class + */ + public final static function create???Filesystem (ManageableApplication $appInstance) { + // Get a new instance + $///Instance = new ???Filesystem(); + + // Return the prepared instance + return $///Instance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filesystem/class_BaseFilesystem.php b/inc/main/classes/filesystem/class_BaseFilesystem.php new file mode 100644 index 00000000..bbaea50e --- /dev/null +++ b/inc/main/classes/filesystem/class_BaseFilesystem.php @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseFilesystem extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/interfaces/filesystem/.htaccess b/inc/main/interfaces/filesystem/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/filesystem/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/filesystem/class_Filesystem.php b/inc/main/interfaces/filesystem/class_Filesystem.php new file mode 100644 index 00000000..e2c4ad5f --- /dev/null +++ b/inc/main/interfaces/filesystem/class_Filesystem.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Filesystem extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/class_CloseableFile.php b/inc/main/interfaces/io/class_CloseableFile.php new file mode 100644 index 00000000..c2608e88 --- /dev/null +++ b/inc/main/interfaces/io/class_CloseableFile.php @@ -0,0 +1,37 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface CloseableFile extends FrameworkInterface { + /** + * Close a file source and set it's instance to null and the file name + * to empty. + * + * @return void + * @throws NullPointerException If the file pointer instance is not set by setPointer() + * @throws InvalidResourceException If there is being set + */ + function closeFile (); +} + +// [EOF] +?> -- 2.39.5