Continued:
[core.git] / framework / main / classes / file_directories / class_BaseAbstractFile.php
index a4f718dccf51b29039c86e3b86d10b2a8957b305..29517f425c0b0c942cf38585d882d9b9c4572f14 100644 (file)
@@ -1,9 +1,12 @@
 <?php
 // Own namespace
-namespace CoreFramework\Filesystem\File;
+namespace Org\Mxchange\CoreFramework\Filesystem\File;
 
 // Import framework stuff
-use CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Filesystem\CloseableFile;
+use Org\Mxchange\CoreFramework\Filesystem\FilePointer;
+use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
+use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 
 /**
  * An abstract file class
@@ -27,17 +30,12 @@ use CoreFramework\Object\BaseFrameworkSystem;
  * 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 BaseAbstractFile extends BaseFrameworkSystem implements FilePointer, CloseableFile {
+abstract class BaseAbstractFile extends BaseFrameworkSystem implements FilePointer, CloseableFile {
        /**
         * Counter for total entries
         */
        private $totalEntries = 0;
 
-       /**
-        * The current file we are working in
-        */
-       private $fileName = '';
-
        /**
         * Protected constructor
         *
@@ -104,33 +102,12 @@ class BaseAbstractFile extends BaseFrameworkSystem implements FilePointer, Close
        }
 
        /**
-        * Getter for the file pointer
+        * Getter for the file object
         *
-        * @return      $filePointer    The file pointer which shall be a valid file resource
-        * @throws      UnsupportedOperationException   If this method is called
+        * @return      $fileObject             An instance of a SplFileObject
         */
-       public final function getPointer () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Setter for file name
-        *
-        * @param       $fileName       The new file name
-        * @return      void
-        */
-       protected final function setFileName ($fileName) {
-               $fileName = (string) $fileName;
-               $this->fileName = $fileName;
-       }
-
-       /**
-        * Getter for file name
-        *
-        * @return      $fileName       The current file name
-        */
-       public final function getFileName () {
-               return $this->fileName;
+       public final function getFileObject () {
+               return $this->getPointerInstance()->getFileObject();
        }
 
        /**
@@ -141,14 +118,11 @@ class BaseAbstractFile extends BaseFrameworkSystem implements FilePointer, Close
         */
        public function closeFile () {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: fileName=%s - CALLED!', __METHOD__, __LINE__, $this->getFileName()));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: CALLED!', __METHOD__, __LINE__));
 
                // Close down pointer instance as well by unsetting it
                $this->unsetPointerInstance();
 
-               // Remove file name
-               $this->setFileName('');
-
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: EXIT!', __METHOD__, __LINE__));
        }
@@ -169,7 +143,7 @@ class BaseAbstractFile extends BaseFrameworkSystem implements FilePointer, Close
         *
         * @return      mixed   The result of fread()
         * @throws      NullPointerException    If the file pointer instance
-        *                                                                      is not set by setPointer()
+        *                                                                      is not set by setFileObject()
         * @throws      InvalidResourceException        If there is being set
         */
        public function readFromFile () {
@@ -181,9 +155,9 @@ class BaseAbstractFile extends BaseFrameworkSystem implements FilePointer, Close
         * Write data to a file pointer
         *
         * @param       $dataStream             The data stream we shall write to the file
-        * @return      mixed                   Number of writes bytes or FALSE on error
+        * @return      mixed                   Number of writes bytes or false on error
         * @throws      NullPointerException    If the file pointer instance
-        *                                                                      is not set by setPointer()
+        *                                                                      is not set by setFileObject()
         * @throws      InvalidResourceException        If there is being set
         *                                                                                      an invalid file resource
         */