Rewritten:
authorRoland Häder <roland@mxchange.org>
Sun, 13 Aug 2017 15:52:22 +0000 (17:52 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 13 Aug 2017 15:52:22 +0000 (17:52 +0200)
- rewrote framework to use more SPL's classes SplFileInfo and SplFileObject
  instead of "bare" PHP functions (more objects, better type-hints)
- this may break a lot other code, please rewrite, too
- updated .gitattributes

Signed-off-by: Roland Häder <roland@mxchange.org>
39 files changed:
.gitattributes
framework/bootstrap/class_FrameworkBootstrap.php
framework/loader/class_ClassLoader.php
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/database/backend/lfdb_legacy/class_CachedLocalFileDatabase.php
framework/main/classes/factories/index/class_FileStackIndexFactory.php
framework/main/classes/file_directories/binary/class_BaseBinaryFile.php
framework/main/classes/file_directories/binary/stack/class_StackFile.php
framework/main/classes/file_directories/class_BaseAbstractFile.php
framework/main/classes/file_directories/class_BaseFileIo.php
framework/main/classes/file_directories/input/raw/class_FrameworkRawFileInputPointer.php
framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php
framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php
framework/main/classes/file_directories/io_stream/class_FileIoStream.php
framework/main/classes/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php
framework/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php
framework/main/classes/file_directories/text/class_BaseTextFile.php
framework/main/classes/file_directories/text/input/csv/class_CsvInputFile.php
framework/main/classes/images/class_BaseImage.php
framework/main/classes/images/extended/class_PngImage.php
framework/main/classes/index/class_BaseIndex.php
framework/main/classes/stacker/file/class_BaseFileStack.php
framework/main/classes/template/class_BaseTemplateEngine.php
framework/main/classes/template/image/class_ImageTemplateEngine.php
framework/main/classes/template/mail/class_MailTemplateEngine.php
framework/main/classes/template/menu/class_MenuTemplateEngine.php
framework/main/classes/tools/console/class_ConsoleTools.php
framework/main/exceptions/file_directory/class_FileIoException.php
framework/main/exceptions/file_directory/class_FileIsEmptyException.php
framework/main/exceptions/file_directory/class_FileNotFoundException.php
framework/main/exceptions/file_directory/class_FileReadProtectedException.php
framework/main/exceptions/file_directory/class_FileWriteProtectedException.php
framework/main/exceptions/file_directory/class_PathWriteProtectedException.php
framework/main/interfaces/block/class_Block.php
framework/main/interfaces/io/class_FilePointer.php
framework/main/interfaces/io/file/class_FileInputStreamer.php
framework/main/interfaces/io/file/class_FileOutputStreamer.php
framework/main/interfaces/io/file/handler/class_IoHandler.php
framework/main/middleware/io/class_FileIoHandler.php

index 17cdcd5..72184ce 100644 (file)
@@ -1,2 +1,33 @@
-# Use Linux/Uni* line-feed for new lines (prevents converting)
-* text=lf
+#
+### Distribute this file on all GIT projects!
+#
+# Autodetect text files
+* text=auto
+
+# Force the following filetypes to have unix eols, so Windows does not break them
+*.* text eol=lf
+
+# Force images/fonts to be handled as binaries
+*.jpg binary
+*.jpeg binary
+*.gif binary
+*.png binary
+*.t3x binary
+*.t3d binary
+*.exe binary
+*.data binary
+*.ttf binary
+*.eof binary
+*.eot binary
+*.swf binary
+*.mov binary
+*.mp4 binary
+*.mp3 binary
+*.ogg binary
+*.flv binary
+*.jar binary
+*.pdf binary
+*.woff* binary
+*.otf binary
+*.z binary
+*.docx binary
index 2af601e..c759f94 100644 (file)
@@ -22,6 +22,7 @@ use CoreFramework\Response\Responseable;
 // Import SPL stuff
 use \BadMethodCallException;
 use \InvalidArgumentException;
+use \SplFileInfo;
 
 /**
  * A framework-bootstrap class which helps the frameworks to bootstrap ... ;-)
@@ -137,24 +138,27 @@ final class FrameworkBootstrap {
         * gurantee that the file is actually readable and/or writeable. If you need
         * such gurantee then please use isReadableFile() instead.
         *
-        * @param       $filePathName   Name of the file/path to be checked
+        * @param       $fileInstance   An instance of a SplFileInfo class
         * @return      $isReachable    Whether it is within open_basedir()
         */
-       public static function isReachableFilePath ($filePathName) {
+       public static function isReachableFilePath (SplFileInfo $fileInstance) {
                // Is not reachable by default
                $isReachable = false;
 
                // Get open_basedir parameter
-               $openBaseDir = ini_get('open_basedir');
+               $openBaseDir = trim(ini_get('open_basedir'));
 
                // Is it set?
                if (!empty($openBaseDir)) {
                        // Check all entries
                        foreach (explode(PATH_SEPARATOR, $openBaseDir) as $dir) {
                                // Check on existence
-                               if (substr($filePathName, 0, strlen($dir)) == $dir) {
+                               if (substr($fileInstance->getPathname(), 0, strlen($dir)) == $dir) {
                                        // Is reachable
                                        $isReachable = true;
+
+                                       // Abort lookup as it has been found in open_basedir
+                                       break;
                                } // END - if
                        } // END - foreach
                } else {
@@ -170,23 +174,21 @@ final class FrameworkBootstrap {
         * Checks whether the give file is within open_basedir() (done by
         * isReachableFilePath()), is actually a file and is readable.
         *
-        * @param       $fileName               Name of the file to be checked
+        * @param       $fileInstance   An instance of a SplFileInfo class
         * @return      $isReadable             Whether the file is readable (and therefor exists)
         */
-       public static function isReadableFile ($fileName) {
+       public static function isReadableFile (SplFileInfo $fileInstance) {
                // Default is not readable
                $isReadable = false;
 
-               // Is within parameters, so check if it is a file and readable
+               // Check if it is a file and readable
                $isReadable = (
                        (
-                               self::isReachableFilePath($fileName)
-                       ) && (
-                               file_exists($fileName)
+                               self::isReachableFilePath($fileInstance)
                        ) && (
-                               is_file($fileName)
+                               $fileInstance->isFile()
                        ) && (
-                               is_readable($fileName)
+                               $fileInstance->isReadable()
                        )
                );
 
@@ -197,22 +199,22 @@ final class FrameworkBootstrap {
        /**
         * Loads given include file
         *
-        * @param       $fqfn   Include's FQFN
+        * @param       $fileInstance   An instance of a SplFileInfo class
         * @return      void
-        * @throws      InvalidArgumentException        If $fqfn was not found or not readable or deprecated
+        * @throws      InvalidArgumentException        If file was not found or not readable or deprecated
         */
-       public static function loadInclude ($fqfn) {
+       public static function loadInclude (SplFileInfo $fileInstance) {
                // Trace message
-               //* NOISY-DEBUG: */ printf('[%s:%d]: fqfn=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $fqfn);
+               //* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $fileInstance);
 
                // Should be there ...
-               if (!self::isReadableFile($fqfn)) {
+               if (!self::isReadableFile($fileInstance)) {
                        // Abort here
-                       throw new InvalidArgumentException(sprintf('Cannot find fqfn=%s.', $fqfn));
+                       throw new InvalidArgumentException(sprintf('Cannot find fileInstance.pathname=%s.', $fileInstance->getPathname()));
                } // END - if
 
                // Load it
-               require $fqfn;
+               require $fileInstance->getPathname();
 
                // Trace message
                //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
@@ -225,12 +227,12 @@ final class FrameworkBootstrap {
         */
        public static function doBootstrap () {
                // Load basic include files to continue bootstrapping
-               self::loadInclude(sprintf('%smain%sinterfaces%sclass_FrameworkInterface.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR));
-               self::loadInclude(sprintf('%smain%sinterfaces%sregistry%sclass_Registerable.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR));
-               self::loadInclude(sprintf('%sconfig%sclass_FrameworkConfiguration.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR));
+               self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sclass_FrameworkInterface.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
+               self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sregistry%sclass_Registerable.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
+               self::loadInclude(new SplFileInfo(sprintf('%sconfig%sclass_FrameworkConfiguration.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR)));
 
                // Load global configuration
-               self::loadInclude(sprintf('%s%s', ApplicationEntryPoint::detectFrameworkPath(), 'config-global.php'));
+               self::loadInclude(new SplFileInfo(sprintf('%s%s', ApplicationEntryPoint::detectFrameworkPath(), 'config-global.php')));
        }
 
        /**
@@ -282,17 +284,17 @@ final class FrameworkBootstrap {
                 * warning at the user.
                 */
                foreach (self::$configAppIncludes as $fileName => $status) {
-                       // Construct FQFN
-                       $fqfn = sprintf('%s%s.php', $fullPath, $fileName);
+                       // Construct file instance
+                       $fileInstance = new SplFileInfo(sprintf('%s%s.php', $fullPath, $fileName));
 
                        // Determine if this file is wanted/readable/deprecated
-                       if (($status == 'required') && (!self::isReadableFile($fqfn))) {
+                       if (($status == 'required') && (!self::isReadableFile($fileInstance))) {
                                // Nope, required file cannot be found/read from
-                               ApplicationEntryPoint::exitApplication(sprintf('Application "%s" does not have required file "%s.php". Please add it.', $application, $fileName));
-                       } elseif ((file_exists($fqfn)) && (!is_readable($fqfn))) {
+                               ApplicationEntryPoint::exitApplication(sprintf('Application "%s" does not have required file "%s.php". Please add it.', $application, $fileInstance->getBasename()));
+                       } elseif (($fileInstance->isFile()) && (!$fileInstance->isReadable())) {
                                // Found, not readable file
-                               ApplicationEntryPoint::exitApplication(sprintf('File "%s.php" from application "%s" cannot be read. Please fix CHMOD.', $fileName, $application));
-                       } elseif (($status != 'required') && (!self::isReadableFile($fqfn))) {
+                               ApplicationEntryPoint::exitApplication(sprintf('File "%s.php" from application "%s" cannot be read. Please fix CHMOD.', $fileInstance->getBasename(), $application));
+                       } elseif (($status != 'required') && (!self::isReadableFile($fileInstance))) {
                                // Not found but optional/deprecated file, skip it
                                continue;
                        }
@@ -307,7 +309,7 @@ final class FrameworkBootstrap {
                        } // END - if
 
                        // Load it
-                       self::loadInclude($fqfn);
+                       self::loadInclude($fileInstance);
                } // END - foreach
 
                // Scan for application's classes, exceptions and interfaces
@@ -334,19 +336,19 @@ final class FrameworkBootstrap {
                // Some sanity checks
                if ((empty($applicationInstance)) || (is_null($applicationInstance))) {
                        // Something went wrong!
-                       ApplicationEntryPoint::exitApplication(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because the helper class <span class=\"class_name\">%s</span> is not loaded.",
+                       ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the helper class <span class="class_name">%s</span> is not loaded.',
                                $application,
                                'CoreFramework\Helper\Application\ApplicationHelper'
                        ));
                } elseif (!is_object($applicationInstance)) {
                        // No object!
-                       ApplicationEntryPoint::exitApplication(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because &#39;app&#39; is not an object (%s).",
+                       ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because &#39;app&#39; is not an object (%s).',
                                $application,
                                gettype($applicationInstance)
                        ));
                } elseif (!($applicationInstance instanceof ManageableApplication)) {
                        // Missing interface
-                       ApplicationEntryPoint::exitApplication(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because &#39;app&#39; is lacking required interface ManageableApplication.",
+                       ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because &#39;app&#39; is lacking required interface ManageableApplication.',
                                $application
                        ));
                }
@@ -361,7 +363,7 @@ final class FrameworkBootstrap {
 
                        // Call method
                        call_user_func(array($applicationInstance, $methodName));
-               } // END - if
+               } // END - foreach
        }
 
        /**
@@ -463,25 +465,6 @@ final class FrameworkBootstrap {
        }
 
        /**
-        * Detects the HTTPS flag
-        *
-        * @return      $https  The detected HTTPS flag or null if failed
-        */
-       public static function detectHttpSecured () {
-               // Default is null
-               $https = NULL;
-
-               // Is HTTPS set?
-               if (self::isHttpSecured()) {
-                       // Then use it
-                       $https = $_SERVER['HTTPS'];
-               } // END - if
-
-               // Return it
-               return $https;
-       }
-
-       /**
         * Checks whether HTTPS is set in $_SERVER
         *
         * @return      $isset  Whether HTTPS is set
@@ -507,7 +490,7 @@ final class FrameworkBootstrap {
                } // END - if
 
                // Construct the full URL and secure it against CSRF attacks
-               $baseUrl = $protocol . '://' . self::detectDomain() . self::detectScriptPath();
+               $baseUrl = sprintf('%s://%s%s', $protocol, self::detectDomain(), self::detectScriptPath());
 
                // Return the URL
                return $baseUrl;
index 9f78f96..63f6d00 100644 (file)
@@ -10,6 +10,7 @@ use CoreFramework\Configuration\FrameworkConfiguration;
 use \InvalidArgumentException;
 use \RecursiveDirectoryIterator;
 use \RecursiveIteratorIterator;
+use \SplFileInfo;
 
 /**
  * This class loads class include files with a specific prefix and suffix
@@ -100,14 +101,14 @@ class ClassLoader {
        private $classesCached = false;
 
        /**
-        * Filename for the list cache
+        * SplFileInfo for the list cache
         */
-       private $listCacheFQFN = '';
+       private $listCacheFile = NULL;
 
        /**
-        * Cache for class content
+        * SplFileInfo for class content
         */
-       private $classCacheFQFN = '';
+       private $classCacheFile = NULL;
 
        /**
         * Counter for loaded include files
@@ -160,20 +161,32 @@ class ClassLoader {
                if ($this->listCached === false) {
                        // Writes the cache file of our list away
                        $cacheContent = json_encode($this->foundClasses);
-                       file_put_contents($this->listCacheFQFN, $cacheContent);
+
+                       // Open cache instance
+                       $fileObject = $this->listCacheFile->openFile('w');
+
+                       // And write whole list
+                       $fileObject->fwrite($cacheContent);
                } // END - if
 
                // Skip here if already cached
                if ($this->classesCached === false) {
                        // Generate a full-cache of all classes
                        $cacheContent = '';
-                       foreach (array_keys($this->loadedClasses) as $fqfn) {
+                       foreach (array_keys($this->loadedClasses) as $fileInstance) {
+                               // Open file
+                               $fileObject = $fileInstance->openFile('r');
+
                                // Load the file
-                               $cacheContent .= file_get_contents($fqfn);
+                               // @TODO Add some uglifying code (compress) here
+                               $cacheContent .= $fileObject->fread($fileInstance->getSize());
                        } // END - foreach
 
+                       // Open file
+                       $fileObject = $this->classCacheFile->openFile('w');
+
                        // And write it away
-                       file_put_contents($this->classCacheFQFN, $cacheContent);
+                       $fileObject->fwrite($cacheContent);
                } // END - if
        }
 
@@ -444,11 +457,8 @@ class ClassLoader {
                        // Get filename from iterator which is the class' name (according naming-convention)
                        $fileName = $currentEntry->getFileName();
 
-                       // Get the "FQFN" (path and file name)
-                       $fqfn = $currentEntry->getRealPath();
-
                        // Current entry must be a file, not smaller than 100 bytes and not on ignore list
-                       if ((!$currentEntry->isFile()) || (in_array($fileName, $this->ignoreList)) || (filesize($fqfn) < 100)) {
+                       if ((!$currentEntry->isFile()) || (in_array($fileName, $this->ignoreList)) || ($currentEntry->getSize() < 100)) {
                                // Advance to next entry
                                $iteratorInstance->next();
 
@@ -461,11 +471,11 @@ class ClassLoader {
                        //* NOISY-DEBUG: */ printf('[%s:%d] FOUND: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
                        if ((substr($fileName, 0, strlen($this->prefix)) == $this->prefix) && (substr($fileName, -strlen($this->suffix), strlen($this->suffix)) == $this->suffix)) {
                                // Add it to the list
-                               //* NOISY-DEBUG: */ printf('[%s:%d] ADD: %s,fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $fqfn);
-                               $this->foundClasses[$fileName] = $fqfn;
+                               //* NOISY-DEBUG: */ printf('[%s:%d] ADD: %s,currentEntry=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $currentEntry);
+                               $this->foundClasses[$fileName] = $currentEntry;
                        } else {
                                // Not added
-                               //* NOISY-DEBUG: */ printf('[%s:%d] NOT ADDED: %s,fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $fqfn);
+                               //* NOISY-DEBUG: */ printf('[%s:%d] NOT ADDED: %s,currentEntry=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $currentEntry);
                        }
 
                        // Advance to next entry
@@ -486,8 +496,8 @@ class ClassLoader {
 
                // Construct the FQFN for the cache
                if (!defined('DEVELOPER')) {
-                       $this->listCacheFQFN  = $this->configInstance->getConfigEntry('local_database_path') . 'list-' . $this->configInstance->getConfigEntry('detected_app_name') . '.cache';
-                       $this->classCacheFQFN = $this->configInstance->getConfigEntry('local_database_path') . 'class-' . $this->configInstance->getConfigEntry('detected_app_name') . '.cache';
+                       $this->listCacheFile  = new SplFileInfo($this->configInstance->getConfigEntry('local_database_path') . 'list-' . $this->configInstance->getConfigEntry('detected_app_name') . '.cache');
+                       $this->classCacheFile = new SplFileInfo($this->configInstance->getConfigEntry('local_database_path') . 'class-' . $this->configInstance->getConfigEntry('detected_app_name') . '.cache');
                } // END - if
 
                // Set suffix and prefix from configuration
@@ -502,19 +512,19 @@ class ClassLoader {
                        return;
                } // END - if
 
-               // IS the cache there?
-               if (FrameworkBootstrap::isReadableFile($this->listCacheFQFN)) {
+               // Is the cache there?
+               if (FrameworkBootstrap::isReadableFile($this->listCacheFile)) {
                        // Load and convert it
-                       $this->foundClasses = json_decode(file_get_contents($this->listCacheFQFN));
+                       $this->foundClasses = json_decode(file_get_contents($this->listCacheFile->getPathname()));
 
                        // List has been restored from cache!
                        $this->listCached = true;
                } // END - if
 
                // Does the class cache exist?
-               if (FrameworkBootstrap::isReadableFile($this->listCacheFQFN)) {
+               if (FrameworkBootstrap::isReadableFile($this->classCacheFile)) {
                        // Then include it
-                       FrameworkBootstrap::loadInclude($this->classCacheFQFN);
+                       FrameworkBootstrap::loadInclude($this->classCacheFile);
 
                        // Mark the class cache as loaded
                        $this->classesCached = true;
@@ -547,11 +557,11 @@ class ClassLoader {
                $shortClassName = array_pop($classNameParts);
 
                // Create a name with prefix and suffix
-               $fileName = $this->prefix . $shortClassName . $this->suffix;
+               $fileName = sprintf('%s%s%s', $this->prefix, $shortClassName, $this->suffix);
 
                // Now look it up in our index
                //* NOISY-DEBUG: */ printf('[%s:%d] ISSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
-               if ((isset($this->foundClasses[$fileName])) && (!isset($this->loadedClasses[$this->foundClasses[$fileName]]))) {
+               if ((isset($this->foundClasses[$fileName])) && (!isset($this->loadedClasses[$this->foundClasses[$fileName]->getPathname()]))) {
                        // File is found and not loaded so load it only once
                        //* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - START' . PHP_EOL, __METHOD__, __LINE__, $fileName);
                        FrameworkBootstrap::loadInclude($this->foundClasses[$fileName]);
@@ -561,7 +571,7 @@ class ClassLoader {
                        $this->total++;
 
                        // Mark this class as loaded for other purposes than loading it.
-                       $this->loadedClasses[$this->foundClasses[$fileName]] = true;
+                       $this->loadedClasses[$this->foundClasses[$fileName]->getPathname()] = true;
 
                        // Remove it from classes list so it won't be found twice.
                        //* NOISY-DEBUG: */ printf('[%s:%d] UNSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
index 56fd139..cc2a0d4 100644 (file)
@@ -52,6 +52,7 @@ use CoreFramework\Visitor\Visitor;
 use \stdClass;
 use \Iterator;
 use \ReflectionClass;
+use \SplFileInfo;
 
 /**
  * The simulator system class is the super class of all other classes. This
@@ -3277,32 +3278,32 @@ Loaded includes:
         * Creates a full-qualified file name (FQFN) for given file name by adding
         * a configured temporary file path to it.
         *
-        * @param       $fileName       Name for temporary file
-        * @return      $fqfn   Full-qualified file name
+        * @param       $infoInstance   An instance of a SplFileInfo class
+        * @return      $tempInstance   An instance of a SplFileInfo class (temporary file)
         * @throw       PathWriteProtectedException If the path in 'temp_file_path' is write-protected
         * @throws      FileIoException If the file cannot be written
         */
-        protected static function createTempPathForFile ($fileName) {
+        protected static function createTempPathForFile (SplFileInfo $infoInstance) {
                // Get config entry
                $basePath = FrameworkConfiguration::getSelfInstance()->getConfigEntry('temp_file_path');
 
                // Is the path writeable?
                if (!is_writable($basePath)) {
                        // Path is write-protected
-                       throw new PathWriteProtectedException($fileName, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN);
+                       throw new PathWriteProtectedException($infoInstance, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN);
                } // END - if
 
                // Add it
-               $fqfn = $basePath . DIRECTORY_SEPARATOR . $fileName;
+               $tempInstance = new SplFileInfo($basePath . DIRECTORY_SEPARATOR . $infoInstance->getBasename());
 
                // Is it reachable?
-               if (!FrameworkBootstrap::isReachableFilePath($fqfn)) {
+               if (!FrameworkBootstrap::isReachableFilePath($tempInstance)) {
                        // Not reachable
-                       throw new FileIoException($fqfn, self::EXCEPTION_FILE_NOT_REACHABLE);
+                       throw new FileIoException($tempInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
                } // END - if
 
                // Return it
-               return $fqfn;
+               return $tempInstance;
         }
 
        /**
index e8a8555..d232db1 100644 (file)
@@ -12,6 +12,9 @@ use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Filesystem\FileNotFoundException;
 use CoreFramework\Generic\FrameworkException;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * Database backend class for storing objects in locally created files.
  *
@@ -114,12 +117,12 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
        /**
         * Setter for the last read file
         *
-        * @param       $fqfn   The FQFN of the last read file
+        * @param       $infoInstance   The FQFN of the last read file
         * @return      void
         */
-       private final function setLastFile ($fqfn) {
+       private final function setLastFile (SplFileInfo $infoInstance) {
                // Cast string and set it
-               $this->lastFile = (string) $fqfn;
+               $this->lastFile = $infoInstance;
        }
 
        /**
@@ -172,20 +175,17 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
        /**
         * Reads a local data file  and returns it's contents in an array
         *
-        * @param       $fqfn   The FQFN for the requested file
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @return      $dataArray
         */
-       private function getDataArrayFromFile ($fqfn) {
+       private function getDataArrayFromFile (SplFileInfo $infoInstance) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: Reading elements from database file ' . $fqfn . ' ...');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: Reading elements from database file ' . $infoInstance . ' ...');
 
                // Init compressed data
-               $compressedData = $this->getFileIoInstance()->loadFileContents($fqfn);
+               $compressedData = $this->getFileIoInstance()->loadFileContents($infoInstance);
                $compressedData = $compressedData['data'];
 
-               // Close the file and throw the instance away
-               unset($fileInstance);
-
                // Decompress it
                $serializedData = $this->getCompressorChannel()->getCompressor()->decompressStream($compressedData);
 
@@ -193,7 +193,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                $dataArray = json_decode($serializedData, true);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: Read ' . count($dataArray) . ' elements from database file ' . $fqfn . '.');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: Read ' . count($dataArray) . ' elements from database file ' . $infoInstance . '.');
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: dataArray=' . print_r($dataArray, true));
 
                // Finally return it
@@ -203,13 +203,13 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
        /**
         * Writes data array to local file
         *
-        * @param       $fqfn           The FQFN of the local file
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @param       $dataArray      An array with all the data we shall write
         * @return      void
         */
-       private function writeDataArrayToFqfn ($fqfn, array $dataArray) {
+       private function writeDataArrayToFqfn (SplFileInfo $infoInstance, array $dataArray) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file ' . $fqfn . ' ...');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file ' . $infoInstance . ' ...');
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: dataArray=' . print_r($dataArray, true));
 
                // Serialize and compress it
@@ -219,7 +219,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: Writing ' . strlen($compressedData) . ' bytes ...');
 
                // Write this data BASE64 encoded to the file
-               $this->getFileIoInstance()->saveStreamToFile($fqfn, $compressedData, $this);
+               $this->getFileIoInstance()->saveStreamToFile($infoInstance, $compressedData, $this);
 
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file completed.');
@@ -236,11 +236,11 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                $infoArray = array();
 
                // Create FQFN for getting the table information file
-               $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, 'info');
+               $infoInstance = $this->generateFileFromDataSet($dataSetInstance, 'info');
 
                // Get the file contents
                try {
-                       $infoArray = $this->getDataArrayFromFile($fqfn);
+                       $infoArray = $this->getDataArrayFromFile($infoInstance);
                } catch (FileNotFoundException $e) {
                        // Not found, so ignore it here
                }
@@ -250,18 +250,18 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
        }
 
        /**
-        * Generates an FQFN from given dataset instance and string
+        * Generates a file info class from given dataset instance and string
         *
         * @param       $dataSetInstance        An instance of a database set class
         * @param       $rowName                        Name of the row
-        * @return      $fqfn                           The FQFN for this row
+        * @return      $infoInstance           An instance of a SplFileInfo class
         */
-       private function generateFqfnFromDataSet (Criteria $dataSetInstance, $rowName) {
-               // This is the FQFN
-               $fqfn = $this->getConfigInstance()->getConfigEntry('local_database_path') . $dataSetInstance->getTableName() . DIRECTORY_SEPARATOR . $rowName . '.' . $this->getFileExtension();
+       private function generateFileFromDataSet (Criteria $dataSetInstance, $rowName) {
+               // Instanciate new file object
+               $infoInstance = new SplFileInfo($this->getConfigInstance()->getConfigEntry('local_database_path') . $dataSetInstance->getTableName() . DIRECTORY_SEPARATOR . $rowName . '.' . $this->getFileExtension());
 
                // Return it
-               return $fqfn;
+               return $infoInstance;
        }
 
        /**
@@ -272,7 +272,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
         */
        private function createTableInfoFile (StoreableCriteria $dataSetInstance) {
                // Create FQFN for creating the table information file
-               $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, 'info');
+               $infoInstance = $this->generateFileFromDataSet($dataSetInstance, 'info');
 
                // Get the data out from dataset in a local array
                $this->tableInfo[$dataSetInstance->getTableName()] = array(
@@ -282,7 +282,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                );
 
                // Write the data to the file
-               $this->writeDataArrayToFqfn($fqfn, $this->tableInfo[$dataSetInstance->getTableName()]);
+               $this->writeDataArrayToFqfn($infoInstance, $this->tableInfo[$dataSetInstance->getTableName()]);
        }
 
        /**
@@ -296,14 +296,14 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                $tableName = $dataSetInstance->getTableName();
 
                // Create FQFN for creating the table information file
-               $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, 'info');
+               $infoInstance = $this->generateFileFromDataSet($dataSetInstance, 'info');
 
                // Get the data out from dataset in a local array
                $this->tableInfo[$tableName]['primary']      = $dataSetInstance->getPrimaryKey();
                $this->tableInfo[$tableName]['last_updated'] = time();
 
                // Write the data to the file
-               $this->writeDataArrayToFqfn($fqfn, $this->tableInfo[$tableName]);
+               $this->writeDataArrayToFqfn($infoInstance, $this->tableInfo[$tableName]);
        }
 
        /**
@@ -475,10 +475,10 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                // Try to save the request away
                try {
                        // Create full path name
-                       $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, md5($dataSetInstance->getUniqueValue()));
+                       $infoInstance = $this->generateFileFromDataSet($dataSetInstance, md5($dataSetInstance->getUniqueValue()));
 
                        // Write the data away
-                       $this->writeDataArrayToFqfn($fqfn, $dataSetInstance->getCriteriaArray());
+                       $this->writeDataArrayToFqfn($infoInstance, $dataSetInstance->getCriteriaArray());
 
                        // Update the primary key
                        $this->updatePrimaryKey($dataSetInstance);
index baf1b38..53633de 100644 (file)
@@ -7,6 +7,9 @@ use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Registry\Registry;
 use CoreFramework\Stacker\Index\IndexableStack;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * A factory class for file-based stack indexes
  *
@@ -43,17 +46,17 @@ class FileStackIndexFactory extends ObjectFactory {
        /**
         * Returns a singleton (registry-based) StackableFile instance
         *
-        * @param       $stackName                      Name of the stack's file
-        * @return      $indexInstance          An instance of a IndexableStack class
+        * @param       $infoInstance   An instance of a SplFileInfo class
+        * @return      $indexInstance  An instance of a IndexableStack class
         */
-       public static final function createFileStackIndexInstance ($fileName, $type) {
+       public static final function createFileStackIndexInstance (SplFileInfo $infoInstance, $type) {
                // If there is no handler?
                if (Registry::getRegistry()->instanceExists($type . '_index')) {
                        // Get handler from registry
                        $indexInstance = Registry::getRegistry()->getInstance($type . '_index');
                } else {
                        // Get the handler instance
-                       $indexInstance = self::createObjectByConfiguredName($type . '_file_stack_index_class', array($fileName));
+                       $indexInstance = self::createObjectByConfiguredName($type . '_file_stack_index_class', array($infoInstance));
 
                        // Add check for interface
                        assert($indexInstance instanceof IndexableStack);
index bfbf4db..40abb00 100644 (file)
@@ -8,6 +8,9 @@ use CoreFramework\Filesystem\Block;
 use CoreFramework\Filesystem\Block\CalculatableBlock;
 use CoreFramework\Filesystem\File\BaseAbstractFile;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * A general binary file class
  *
@@ -385,12 +388,12 @@ class BaseBinaryFile extends BaseAbstractFile {
        /**
         * Initializes this file class
         *
-        * @param       $fileName       Name of this abstract file
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @return      void
         */
-       protected function initFile ($fileName) {
+       protected function initFile (SplFileInfo $infoInstance) {
                // Get a file i/o pointer instance
-               $pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($fileName));
+               $pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($infoInstance));
 
                // ... and set it here
                $this->setPointerInstance($pointerInstance);
index 4b72e1b..0742767 100644 (file)
@@ -7,6 +7,9 @@ use CoreFramework\Filesystem\Block;
 use CoreFramework\Filesystem\File\BaseBinaryFile;
 use CoreFramework\Generic\UnsupportedOperationException;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * A stack file class
  *
@@ -43,11 +46,11 @@ class StackFile extends BaseBinaryFile implements Block {
        /**
         * Creates an instance of this File class and prepares it for usage
         *
-        * @param       $fileName               Name of the stack file
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @param       $blockInstance  An instance of a Block class
         * @return      $fileInstance   An instance of this File class
         */
-       public final static function createStackFile ($fileName, Block $blockInstance) {
+       public final static function createStackFile (SplFileInfo $infoInstance, Block $blockInstance) {
                // Get a new instance
                $fileInstance = new StackFile();
 
@@ -55,7 +58,7 @@ class StackFile extends BaseBinaryFile implements Block {
                $fileInstance->setBlockInstance($blockInstance);
 
                // Init this abstract file
-               $fileInstance->initFile($fileName);
+               $fileInstance->initFile($infoInstance);
 
                // Return the prepared instance
                return $fileInstance;
index 7f827a8..0039274 100644 (file)
@@ -37,11 +37,6 @@ class BaseAbstractFile extends BaseFrameworkSystem implements FilePointer, Close
        private $totalEntries = 0;
 
        /**
-        * The current file we are working in
-        */
-       private $fileName = '';
-
-       /**
         * Protected constructor
         *
         * @param       $className      Name of the class
@@ -107,36 +102,16 @@ 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
+        * @return      $fileObject             An instance of a SplFileObject
         * @throws      UnsupportedOperationException   If this method is called
         */
-       public final function getPointer () {
+       public final function getFileObject () {
                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;
-       }
-
-       /**
         * Close a file source and set it's instance to null and the file name
         * to empty
         *
@@ -144,14 +119,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__));
        }
index 4ba2e96..1205ebe 100644 (file)
@@ -8,6 +8,9 @@ use CoreFramework\Filesystem\FilePointer;
 use CoreFramework\Generic\NullPointerException;
 use CoreFramework\Object\BaseFrameworkSystem;
 
+// Import SPL stuff
+use \SplFileObject;
+
 /**
  * A general FileIo class
  *
@@ -32,14 +35,9 @@ use CoreFramework\Object\BaseFrameworkSystem;
  */
 class BaseFileIo extends BaseFrameworkSystem implements FilePointer, CloseableFile {
        /**
-        * The current file we are working in
+        * The file object
         */
-       private $fileName = '';
-
-       /**
-        * The file pointer
-        */
-       private $filePointer = NULL;
+       private $fileObject = NULL;
 
        /**
         * Protected constructor
@@ -59,7 +57,7 @@ class BaseFileIo extends BaseFrameworkSystem implements FilePointer, CloseableFi
         */
        public final function __destruct() {
                // Is there a resource pointer? Then we have to close the file here!
-               if (is_resource($this->getPointer())) {
+               if (is_object($this->getFileObject())) {
                        // Try to close a file
                        $this->closeFile();
                } // END - if
@@ -74,69 +72,57 @@ class BaseFileIo extends BaseFrameworkSystem implements FilePointer, CloseableFi
         *
         * @return      void
         * @throws      NullPointerException    If the file pointer instance is not set by setPointer()
-        * @throws      InvalidResourceException        If there is being set
+        * @throws      LogicException  If there is no object being set
         */
        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]: fileName=%s - CALLED!', __METHOD__, __LINE__, $this->getFileObject()->getPathname()));
 
-               if (is_null($this->getPointer())) {
+               if (is_null($this->getFileObject())) {
                        // Pointer not initialized
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_resource($this->getPointer())) {
+               } elseif (!is_object($this->getFileObject())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
+                       throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())));
                }
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->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->getFileObject()->getPathname()));
 
-               // Close the file pointer and reset the instance variable
-               @fclose($this->getPointer());
-               $this->setPointer(NULL);
-               $this->setFileName('');
+               // Close the file pointer by NULL-ing it
+               $this->resetFileObject();
 
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: EXIT!', __METHOD__, __LINE__));
        }
 
        /**
-        * Setter for the file pointer
+        * Resets file object instance to NULL
         *
-        * @param       $filePointer    File resource
         * @return      void
         */
-       protected final function setPointer ($filePointer) {
-               $this->filePointer = $filePointer;
-       }
-
-       /**
-        * Getter for the file pointer
-        *
-        * @return      $filePointer    The file pointer which shall be a valid file resource
-        */
-       public final function getPointer () {
-               return $this->filePointer;
+       protected final function resetFileObject () {
+               // Set it to NULL
+               $this->fileObject = NULL;
        }
 
        /**
-        * Setter for file name
+        * Setter for the file object
         *
-        * @param       $fileName       The new file name
+        * @param       $fileObject             An instance of a SplFileObject class
         * @return      void
         */
-       protected final function setFileName ($fileName) {
-               $fileName = (string) $fileName;
-               $this->fileName = $fileName;
+       protected final function setFileObject (SplFileObject $fileObject) {
+               $this->fileObject = $fileObject;
        }
 
        /**
-        * Getter for file name
+        * Getter for the file object
         *
-        * @return      $fileName       The current file name
+        * @return      $fileObject             An instance of a SplFileObject class
         */
-       public final function getFileName () {
-               return $this->fileName;
+       public final function getFileObject () {
+               return $this->fileObject;
        }
 
        /**
@@ -145,7 +131,7 @@ class BaseFileIo extends BaseFrameworkSystem implements FilePointer, CloseableFi
         * @return      $seekPosition   Current seek position
         */
        public final function determineSeekPosition () {
-               return ftell($this->getPointer());
+               return $this->getFileObject()->ftell();
        }
 
        /**
@@ -154,7 +140,7 @@ class BaseFileIo extends BaseFrameworkSystem implements FilePointer, CloseableFi
         * @return      $isEndOfFileReached             Whether the EOF has been reached
         */
        public final function isEndOfFileReached () {
-               return feof($this->getPointer());
+               return $this->getFileObject()->feof();
        }
 
        /**
@@ -166,7 +152,7 @@ class BaseFileIo extends BaseFrameworkSystem implements FilePointer, CloseableFi
         */
        public function seek ($offset, $whence = SEEK_SET) {
                // Seek to position
-               $status = fseek($this->getPointer(), $offset, $whence);
+               $status = $this->getFileObject()->fseek($offset, $whence);
 
                // Return status
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] status=%d', __METHOD__, __LINE__, $status));
index 728160a..3e1635e 100644 (file)
@@ -12,6 +12,9 @@ use CoreFramework\Generic\NullPointerException;
 use CoreFramework\Generic\UnsupportedOperationException;
 use CoreFramework\Object\BaseFrameworkSystem;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * A class for reading files
  *
@@ -49,42 +52,37 @@ class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer {
         * Create a file pointer based on the given file. The file will also
         * be verified here.
         *
-        * @param       $fileName       The file name we shall pass to fopen()
-        * @throws      FileIsEmptyException            If the provided file name is empty.
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @throws      FileIoException                         If the file is not reachable
         * @throws      FileReadProtectedException      If the file is not found or cannot be read
         * @throws      FileNotFoundException           If the file does not exist
         * @return      void
         */
-       public static final function createFrameworkRawFileInputPointer ($fileName) {
+       public static final function createFrameworkRawFileInputPointer (SplFileInfo $infoInstance) {
                // Some pre-sanity checks...
-               if ((is_null($fileName)) || (empty($fileName))) {
-                       // No filename given
-                       throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!FrameworkBootstrap::isReachableFilePath($fileName)) {
+               if (!FrameworkBootstrap::isReachableFilePath($infoInstance)) {
                        // File cannot be accessed (due to open_basedir restriction)
-                       throw new FileIoException($fileName, self::EXCEPTION_FILE_NOT_REACHABLE);
-               } elseif ((!FrameworkBootstrap::isReadableFile($fileName)) && (file_exists($fileName))) {
-                       // File exists but cannot be read from
-                       throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ);
-               } elseif ((!FrameworkBootstrap::isReadableFile($fileName)) && (!file_exists($fileName))) {
+                       throw new FileIoException($infoInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
+               } elseif ((!FrameworkBootstrap::isReadableFile($infoInstance)) && (!$infoInstance->isFile())) {
                        // File does not exist
-                       throw new FileNotFoundException($fileName, self::EXCEPTION_FILE_NOT_FOUND);
+                       throw new FileNotFoundException($infoInstance, self::EXCEPTION_FILE_NOT_FOUND);
+               } elseif ((!FrameworkBootstrap::isReadableFile($infoInstance)) && ($infoInstance->isFile())) {
+                       // File exists but cannot be read from
+                       throw new FileReadProtectedException($infoInstance, self::EXCEPTION_FILE_CANNOT_BE_READ);
                }
 
                // Try to open a handler
-               $filePointer = fopen($fileName, 'rb');
-               if ((is_null($filePointer)) || ($filePointer === false)) {
+               $fileObject = $infoInstance->openFile('rb');
+               if ((is_null($fileObject)) || ($fileObject === false)) {
                        // Something bad happend
-                       throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID);
+                       throw new FileIoException($infoInstance, self::EXCEPTION_FILE_POINTER_INVALID);
                } // END - if
 
                // Create new instance
                $pointerInstance = new FrameworkRawFileInputPointer();
 
                // Set file pointer and file name
-               $pointerInstance->setPointer($filePointer);
-               $pointerInstance->setFileName($fileName);
+               $pointerInstance->setFileObject($fileObject);
 
                // Return the instance
                return $pointerInstance;
@@ -94,17 +92,16 @@ class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer {
         * Read data a file pointer
         *
         * @return      mixed   The result of fread()
-        * @throws      NullPointerException    If the file pointer instance
-        *                                                                      is not set by setPointer()
-        * @throws      InvalidResourceException        If there is being set
+        * @throws      NullPointerException    If the file pointer instance is not set by setPointer()
+        * @throws      LogicException  If there is no object being set
         */
        public function readFromFile () {
-               if (is_null($this->getPointer())) {
+               if (is_null($this->getFileObject())) {
                        // Pointer not initialized
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_resource($this->getPointer())) {
+               } elseif (!is_object($this->getFileObject())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
+                       throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())));
                }
 
                // Read data from the file pointer and return it
@@ -133,7 +130,7 @@ class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer {
                assert(is_int($bytes));
 
                // Try to read given characters
-               $data = fread($this->getPointer(), $bytes);
+               $data = $this->getFileObject()->fread($bytes);
 
                // Then return it
                return $data;
index f8efef6..0fdd439 100644 (file)
@@ -55,35 +55,30 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
         * @throws      FileReadProtectedException      If the file cannot be read from
         * @return      void
         */
-       public static final function createFrameworkTextFileInputPointer ($fileName) {
-               // Some pre-sanity checks...
-               if ((is_null($fileName)) || (empty($fileName))) {
-                       // No filename given
-                       throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!FrameworkBootstrap::isReachableFilePath($fileName)) {
+       public static final function createFrameworkTextFileInputPointer ($infoInstance) {
+               if (!FrameworkBootstrap::isReachableFilePath($infoInstance)) {
                        // File cannot be reached
-                       throw new FileIoException($fileName, self::EXCEPTION_FILE_NOT_REACHABLE);
-               } elseif ((!FrameworkBootstrap::isReadableFile($fileName)) && (!file_exists($fileName))) {
+                       throw new FileIoException($infoInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
+               } elseif ((!FrameworkBootstrap::isReadableFile($infoInstance)) && (!$infoInstance->isFile())) {
                        // File does not exist!
-                       throw new FileNotFoundException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ);
-               } elseif ((!FrameworkBootstrap::isReadableFile($fileName)) && (file_exists($fileName))) {
+                       throw new FileNotFoundException($infoInstance, self::EXCEPTION_FILE_CANNOT_BE_READ);
+               } elseif ((!FrameworkBootstrap::isReadableFile($infoInstance)) && ($infoInstance->isFile())) {
                        // File cannot be read from (but exists)
-                       throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ);
+                       throw new FileReadProtectedException($infoInstance, self::EXCEPTION_FILE_CANNOT_BE_READ);
                }
 
                // Try to open a handler
-               $filePointer = fopen($fileName, 'r');
-               if ((is_null($filePointer)) || ($filePointer === false)) {
+               $fileObject = $infoInstance->openFile('r');
+               if ((is_null($fileObject)) || ($fileObject === false)) {
                        // Something bad happend
-                       throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID);
+                       throw new FileIoException($infoInstance, self::EXCEPTION_FILE_POINTER_INVALID);
                } // END - if
 
                // Create new instance
                $pointerInstance = new FrameworkTextFileInputPointer();
 
                // Set file pointer and file name
-               $pointerInstance->setPointer($filePointer);
-               $pointerInstance->setFileName($fileName);
+               $pointerInstance->setPointer($fileObject);
 
                // Return the instance
                return $pointerInstance;
@@ -114,27 +109,26 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
         *
         * @param       $bytes  Amount of bytes to read or whole line (only text files)
         * @return      $data   Data read from file
-        * @throws      NullPointerException    If the file pointer instance
-        *                                                                      is not set by setPointer()
-        * @throws      InvalidResourceException        If there is being set
+        * @throws      NullPointerException    If the file pointer instance is not set by setPointer()
+        * @throws      InvalidResourceException        If there is no object being set
         */
        public function read ($bytes = NULL) {
                // Some sanity checks
-               if (is_null($this->getPointer())) {
+               if (is_null($this->getFileObject())) {
                        // Pointer not initialized
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_resource($this->getPointer())) {
+               } elseif (!is_object($this->getFileObject())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
+                       throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())));
                }
 
                // Is $bytes set?
                if (is_int($bytes)) {
                        // Try to read given characters
-                       $data = fgets($this->getPointer(), $bytes);
+                       $data = $this->getFileObject()->fread($bytes);
                } else {
                        // Try to read whole line
-                       $data = fgets($this->getPointer());
+                       $data = $this->getFileObject()->fgets();
                }
 
                // Then return it
index e1a0b59..c9c9ca5 100644 (file)
@@ -12,6 +12,9 @@ use CoreFramework\Generic\NullPointerException;
 use CoreFramework\Generic\UnsupportedOperationException;
 use CoreFramework\Object\BaseFrameworkSystem;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * A class for reading files
  *
@@ -49,46 +52,43 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         * Create a file pointer based on the given file. The file will also
         * be verified here.
         *
-        * @param       $fileName       The file name we shall pass to fopen()
+        * @param       $fileInstance   An instance of a SplFileInfo class
         * @return      void
-        * @throws      FileIsEmptyException            If the given file name is NULL or empty
         * @throws      FileReadProtectedException      If PHP cannot read an existing file
         * @throws      FileWriteProtectedException     If PHP cannot write an existing file
         * @throws      PathWriteProtectedException     If PHP cannot write to an existing path
         * @throws      FileIoException                         If fopen() returns not a file resource
         */
-       public static final function createFrameworkFileInputOutputPointer ($fileName) {
+       public static final function createFrameworkFileInputOutputPointer (SplFileInfo $fileInstance) {
                // Some pre-sanity checks...
-               if ((is_null($fileName)) || (empty($fileName))) {
-                       // No filename given
-                       throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!FrameworkBootstrap::isReachableFilePath($fileName)) {
+               if (!FrameworkBootstrap::isReachableFilePath($fileInstance)) {
                        // File exists but cannot be read
-                       throw new FileIoException($fileName, self::EXCEPTION_FILE_NOT_REACHABLE);
-               } elseif ((!FrameworkBootstrap::isReadableFile($fileName)) && (file_exists($fileName))) {
+                       throw new FileIoException($fileInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
+               } elseif ((!FrameworkBootstrap::isReadableFile($fileInstance)) && (file_exists($fileInstance))) {
                        // File exists but cannot be read
-                       throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ);
-               } elseif ((file_exists($fileName)) && (!is_writable($fileName))) {
+                       throw new FileReadProtectedException($fileInstance, self::EXCEPTION_FILE_CANNOT_BE_READ);
+               } elseif (($fileInstance->isFile()) && (!$fileInstance->isWritable())) {
                        // File exists but cannot be written
-                       throw new FileWriteProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_WRITTEN);
-               } elseif (!is_writable(dirname($fileName))) {
+                       throw new FileWriteProtectedException($fileInstance, self::EXCEPTION_FILE_CANNOT_BE_WRITTEN);
+               } elseif (!is_writable($fileInstance->getPath())) {
                        // Path is not writable
-                       throw new PathWriteProtectedException($fileName, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN);
+                       throw new PathWriteProtectedException($fileInstance, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN);
                }
 
                // Try to open a handler
-               $filePointer = fopen($fileName, 'c+b');
-               if ((is_null($filePointer)) || ($filePointer === false)) {
+               $fileObject = $fileInstance->openFile('c+b');
+
+               // Is it valid?
+               if ((is_null($fileObject)) || ($fileObject === false)) {
                        // Something bad happend
-                       throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID);
+                       throw new FileIoException($fileInstance->getPathname(), self::EXCEPTION_FILE_POINTER_INVALID);
                } // END - if
 
                // Create new instance
                $pointerInstance = new FrameworkFileInputOutputPointer();
 
-               // Set file pointer and file name
-               $pointerInstance->setPointer($filePointer);
-               $pointerInstance->setFileName($fileName);
+               // Set file object and file name
+               $pointerInstance->setFileObject($fileObject);
 
                // Return the instance
                return $pointerInstance;
@@ -103,16 +103,13 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         * @return      void
         * @throws      NullPointerException    If the file pointer instance
         *                                                                      is not set by setPointer()
-        * @throws      InvalidResourceException        If there is being set
+        * @todo Add more checks
         */
        private function validateFilePointer () {
-               if (is_null($this->getPointer())) {
+               if (is_null($this->getFileObject())) {
                        // Pointer not initialized
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_resource($this->getPointer())) {
-                       // Pointer is not a valid resource!
-                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
-               }
+               } // END - if
 
                // All fine here
        }
@@ -141,7 +138,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                $this->validateFilePointer();
 
                // Write data to the file pointer and return written bytes
-               return fwrite($this->getPointer(), $dataStream, strlen($dataStream));
+               return $this->getFileObject()->fwrite($dataStream, strlen($dataStream));
        }
 
        /**
@@ -169,7 +166,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                $this->validateFilePointer();
 
                // Rewind the pointer
-               return rewind($this->getPointer());
+               return $this->getFileObject()->rewind();
        }
 
        /**
@@ -184,7 +181,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                $this->validateFilePointer();
 
                // Move the file pointer
-               return fseek($this->getPointer(), $seekPosition, $whence);
+               return $this->getFileObject()->fseek($seekPosition, $whence);
        }
 
        /**
@@ -210,10 +207,10 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                // Is $bytes set?
                if (is_int($bytes)) {
                        // Try to read given characters
-                       $data = fread($this->getPointer(), $bytes);
+                       $data = $this->getFileObject()->fread($bytes);
                } else {
                        // Try to read whole line
-                       $data = fread($this->getPointer());
+                       $data = $this->getFileObject()->fgets();
                }
 
                // Then return it
@@ -273,7 +270,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                $this->validateFilePointer();
 
                // Get file's data
-               $fileData = fstat($this->getPointer());
+               $fileData = $this->getFileObject()->fstat();
 
                // Make sure the required array key is there
                assert(isset($fileData['size']));
index 51406cb..25919e3 100644 (file)
@@ -11,6 +11,9 @@ use CoreFramework\Object\BaseFrameworkSystem;
 use CoreFramework\Stream\Filesystem\FileInputStreamer;
 use CoreFramework\Stream\Filesystem\FileOutputStreamer;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * An universal class for file input/output streams.
  *
@@ -79,13 +82,13 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
        /**
         * Saves data to a given local file and create missing directory structures
         *
-        * @param       $fileName       The file name for the to be saved file
+        * @param       $fileInstance   An instance of a SplFileInfo class
         * @param       $dataArray      The data we shall store to the file
         * @return      void
         * @see         FileOutputStreamer
         * @todo        This method needs heavy rewrite
         */
-       public final function saveFile ($fileName, array $dataArray) {
+       public final function saveFile (SplFileInfo $fileInstance, array $dataArray) {
                // Try it five times
                $dirName = '';
                $fileInstance = NULL;
@@ -93,7 +96,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
                for ($idx = 0; $idx < 5; $idx++) {
                        // Get a file output pointer
                        try {
-                               $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_output_class', array($fileName, 'wb'));
+                               $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_output_class', array($fileInstance, 'wb'));
                        } catch (FileNotFoundException $e) {
                                // Bail out
                                ApplicationEntryPoint::exitApplication('The application has made a fatal error. Exception: ' . $e->__toString() . ' with message: ' . $e->getMessage());
@@ -142,11 +145,11 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
        /**
         * Reads from a local file
         *
-        * @param       $fqfn   The full-qualified file-name which we shall load
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @return      $array  An array with the element 'header' and 'data'
         * @see         FileInputStreamer
         */
-       public final function loadFileContents ($fqfn) {
+       public final function loadFileContents (SplFileInfo $infoInstance) {
                // Initialize some variables and arrays
                $inputBuffer = '';
                $lastBuffer = '';
@@ -155,7 +158,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
                $readData = ''; // This will contain our read data
 
                // Get a file input handler
-               $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($fqfn));
+               $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($infoInstance));
 
                // Read all it's contents (we very and transparently decompress it below)
                while ($readRawLine = $fileInstance->readFromFile()) {
index 4be0c80..a63535c 100644 (file)
@@ -7,6 +7,9 @@ use CoreFramework\FileSystem\BaseFileIo;
 use CoreFramework\Filesystem\Pointer\OutputPointer;
 use CoreFramework\Generic\NullPointerException;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * A class for writing files
  *
@@ -44,32 +47,31 @@ class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer
         * Create a file pointer based on the given file. The file will also
         * be verified here.
         *
-        * @param       $fileName       The file name we shall pass to fopen()
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @param       $mode           The output mode ('w', 'a' are valid)
         * @throws      FileIsEmptyException    If the provided file name is empty.
         * @throws      FileIoException                 If fopen() returns not a file resource
         * @return      void
         */
-       public static final function createFrameworkRawFileOutputPointer ($fileName, $mode) {
+       public static final function createFrameworkRawFileOutputPointer (SplFileInfo $infoInstance, $mode) {
                // Some pre-sanity checks...
-               if (is_null($fileName)) {
-                       // No filename given
+               if (is_null($infoInstance)) {
+                       // No infoInstance given
                        throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } // END - if
 
                // Try to open a handler
-               $filePointer = @fopen($fileName, $mode);
-               if ((is_null($filePointer)) || ($filePointer === false)) {
+               $fileObject = $infoInstance->openFile($mode);
+               if ((is_null($fileObject)) || ($fileObject === false)) {
                        // Something bad happend
-                       throw new FileIoException ($fileName, self::EXCEPTION_FILE_POINTER_INVALID);
+                       throw new FileIoException ($infoInstance, self::EXCEPTION_FILE_POINTER_INVALID);
                } // END - if
 
                // Create new instance
                $pointerInstance = new FrameworkRawFileOutputPointer();
 
                // Set file pointer and file name
-               $pointerInstance->setPointer($filePointer);
-               $pointerInstance->setFileName($fileName);
+               $pointerInstance->setFileObject($fileObject);
 
                // Return the instance
                return $pointerInstance;
@@ -80,22 +82,20 @@ class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer
         *
         * @param       $dataStream             The data stream we shall write to the file
         * @return      mixed                   Number of writes bytes or false on error
-        * @throws      NullPointerException    If the file pointer instance
-        *                                                                      is not set by setPointer()
-        * @throws      InvalidResourceException        If there is being set
-        *                                                                                      an invalid file resource
+        * @throws      NullPointerException    If the file pointer instance is not set by setPointer()
+        * @throws      LogicException  If there is no object being set
         */
        public function writeToFile ($dataStream) {
-               if (is_null($this->getPointer())) {
+               if (is_null($this->getFileObject())) {
                        // Pointer not initialized
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_resource($this->getPointer())) {
+               } elseif (!is_object($this->getFileObject())) {
                        // Pointer is not a valid resource!
-                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
+                       throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())));
                }
 
                // Write data to the file pointer and return written bytes
-               return fwrite($this->getPointer(), $dataStream);
+               return $this->getFileObject()->fwrite($dataStream);
        }
 
        /**
index a235a80..425c57d 100644 (file)
@@ -8,6 +8,9 @@ use CoreFramework\Filesystem\Pointer\OutputPointer;
 use CoreFramework\Generic\NullPointerException;
 use CoreFramework\Generic\UnsupportedOperationException;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * A class for writing files
  *
@@ -45,22 +48,22 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer
         * Create a file pointer based on the given file. The file will also
         * be verified here.
         *
-        * @param       $fileName       The file name we shall pass to fopen()
+        * @param       $fileInstance   An instance of a SplFileInfo class
         * @param       $mode           The output mode ('w', 'a' are valid)
         * @throws      FileIsEmptyException    If the provided file name is empty.
         * @throws      FileIoException                 If fopen() returns not a file resource
         * @return      void
         */
-       public static final function createFrameworkTextFileOutputPointer ($fileName, $mode) {
+       public static final function createFrameworkTextFileOutputPointer (SplFileInfo $fileInstance, $mode) {
                // Some pre-sanity checks...
-               if (is_null($fileName)) {
+               if (is_null($fileInstance)) {
                        // No filename given
                        throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
                } // END - if
 
                // Try to open a handler
-               $filePointer = @fopen($fileName, $mode);
-               if ((is_null($filePointer)) || ($filePointer === false)) {
+               $fileObject = $fileInstance->openFile($mode);
+               if ((is_null($fileObject)) || ($fileObject === false)) {
                        // Something bad happend
                        throw new FileIoException ($fileName, self::EXCEPTION_FILE_POINTER_INVALID);
                } // END - if
@@ -68,9 +71,8 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer
                // Create new instance
                $pointerInstance = new FrameworkTextFileOutputPointer();
 
-               // Set file pointer and file name
-               $pointerInstance->setPointer($filePointer);
-               $pointerInstance->setFileName($fileName);
+               // Set file object
+               $pointerInstance->setFileObject($fileObject);
 
                // Return the instance
                return $pointerInstance;
@@ -81,22 +83,20 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer
         *
         * @param       $dataStream             The data stream we shall write to the file
         * @return      mixed                   Number of writes bytes or false on error
-        * @throws      NullPointerException    If the file pointer instance
-        *                                                                      is not set by setPointer()
-        * @throws      InvalidResourceException        If there is being set
-        *                                                                                      an invalid file resource
+        * @throws      NullPointerException    If the file pointer instance is not set by setPointer()
+        * @throws      LogicException  If there is no object being set
         */
        public function writeToFile ($dataStream) {
-               if (is_null($this->getPointer())) {
+               if (is_null($this->getFileObject())) {
                        // Pointer not initialized
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_resource($this->getPointer())) {
-                       // Pointer is not a valid resource!
-                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
+               } elseif (!is_object($this->getFileObject())) {
+                       // Pointer is not a valid object!
+                       throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())));
                }
 
                // Write data to the file pointer and return written bytes
-               return fwrite($this->getPointer(), $dataStream);
+               return $this->getFileObject()->fwrite($dataStream);
        }
 
        /**
index b37010b..dccc5ae 100644 (file)
@@ -6,6 +6,9 @@ namespace CoreFramework\Filesystem\File;
 use CoreFramework\Filesystem\File\BaseAbstractFile;
 use CoreFramework\Generic\UnsupportedOperationException;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * A general text file class
  *
@@ -66,17 +69,17 @@ class BaseTextFile extends BaseAbstractFile {
        /**
         * Reads from a local or remote file
         *
-        * @param       $fqfn   The file's FQFN we shall load
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @return      $array  An array containing all read lines
         * @throws      InvalidArrayCountException      If an array has not the expected size
         * @throws      InvalidMD5ChecksumException     If two MD5 hashes did not match
         */
-       public function loadFileContents ($fqfn) {
+       public function loadFileContents (SplFileInfo $infoInstance) {
                /*
                 * This class (or its implementations) are special file readers/writers.
                 * There is no need to read/write the whole file.
                 */
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] fqfn=' . $fqfn);
+               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] infoInstance=' . $infoInstance);
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
index 16675fd..75be75c 100644 (file)
@@ -49,9 +49,6 @@ class CsvInputFile extends BaseInputTextFile implements CsvInputStreamer {
                // Get a new instance
                $fileInstance = new CsvInputFile();
 
-               // Set file name
-               $fileInstance->setFileName($fileName);
-
                // Init this abstract file
                $fileInstance->initFile($fileName);
 
index a42c6c1..f2e3433 100644 (file)
@@ -555,10 +555,16 @@ class BaseImage extends BaseFrameworkSystem implements Registerable {
         */
        public function getContent () {
                // Get cache file name
-               $cacheFile = $this->getTemplateInstance()->getImageCacheFqfn();
+               $cacheFile = $this->getTemplateInstance()->getImageCacheFile();
+
+               // Open it for reading
+               $fileObject = $cacheFile->openFile('r');
+
+               // Rewind to beginning
+               $fileObject->rewind();
 
                // Load the content
-               $imageContent = file_get_contents($cacheFile);
+               $imageContent = $fileObject->fread($cacheFile->getSize());
 
                // And return it
                return $imageContent;
index fbf444c..4609960 100644 (file)
@@ -6,6 +6,9 @@ namespace CoreFramework\Image;
 use CoreFramework\Bootstrap\FrameworkBootstrap;
 use CoreFramework\Template\CompileableTemplate;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * A PNG image generator
  *
@@ -63,22 +66,26 @@ class PngImage extends BaseImage {
         * Finish this image by producing it
         *
         * @return      void
+        * @todo Rewrite this to SplFileInfo/Object
         */
        public function finishImage () {
+               $this->partialStub('Unfinished method.');
+               return;
+
                // Call parent method
                parent::finishImage();
 
                // Get a file name for our image
-               $cacheFile = $this->getTemplateInstance()->getImageCacheFqfn();
+               $cacheFile = $this->getTemplateInstance()->getImageCacheFile();
 
                // Does it exist?
                if (FrameworkBootstrap::isReadableFile($cacheFile)) {
                        // Remove it
-                       @unlink($cacheFile);
+                       unlink($cacheFile->getPathname());
                } // END - if
 
                // Finish the image and send it to a cache file
-               imagepng($this->getImageResource(), $cacheFile, 9, PNG_ALL_FILTERS);
+               imagepng($this->getImageResource(), $cacheFile->getPathname(), 9, PNG_ALL_FILTERS);
        }
 
 }
index d661b92..dd28f8a 100644 (file)
@@ -226,16 +226,6 @@ class BaseIndex extends BaseFrameworkSystem {
        }
 
        /**
-        * Getter for file name
-        *
-        * @return      $fileName       The current file name
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function getFileName () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
         * Initializes counter for valid entries, arrays for damaged entries and
         * an array for gap seek positions. If you call this method on your own,
         * please re-analyze the file structure. So you are better to call
index 9d2e015..6734e0e 100644 (file)
@@ -410,16 +410,6 @@ class BaseFileStack extends BaseStacker {
        }
 
        /**
-        * Getter for file name
-        *
-        * @return      $fileName       The current file name
-        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
-        */
-       public function getFileName () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
         * Getter for size of given stack (array count)
         *
         * @param       $stackerName    Name of the stack
index a233e77..5ca3c6a 100644 (file)
@@ -12,6 +12,9 @@ use CoreFramework\Manager\ManageableApplication;
 use CoreFramework\Object\BaseFrameworkSystem;
 use CoreFramework\Response\Responseable;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * A generic template engine
  *
@@ -78,9 +81,9 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        private $compiledData = '';
 
        /**
-        * The last loaded template's FQFN for debugging the engine
+        * The last loaded template's file instance (SplFileInfo)
         */
-       private $lastTemplate = '';
+       private $lastTemplate = NULL;
 
        /**
         * The variable stack for the templates
@@ -494,17 +497,17 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        }
 
        /**
-        * Setter for the last loaded template's FQFN
+        * Setter for the last loaded template's file instance
         *
         * @param       $template       The last loaded template
         * @return      void
         */
-       private final function setLastTemplate ($template) {
-               $this->lastTemplate = (string) $template;
+       private final function setLastTemplate (SplFileInfo $fileInstance) {
+               $this->lastTemplate = $fileInstance;
        }
 
        /**
-        * Getter for the last loaded template's FQFN
+        * Getter for the last loaded template's file instance
         *
         * @return      $template       The last loaded template
         */
@@ -692,19 +695,19 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                 * now entirely done by php_intl. These old thing with language-based
                 * template paths comes from an older time.
                 */
-               $fqfn = sprintf('%s%s%s%s%s%s',
+               $fileInstance = new SplFileInfo(sprintf('%s%s%s%s%s%s',
                        $this->getTemplateBasePath(),
                        $this->getGenericBasePath(),
                        $this->getTemplateType(),
                        DIRECTORY_SEPARATOR,
                        (string) $templateName,
                        $ext
-               );
+               ));
 
                // First try this
                try {
                        // Load the raw template data
-                       $this->loadRawTemplateData($fqfn);
+                       $this->loadRawTemplateData($fileInstance);
                } catch (FileNotFoundException $e) {
                        // If we shall load a code-template we need to switch the file extension
                        if (($this->getTemplateType() != $this->getConfigInstance()->getConfigEntry('html_template_type')) && (empty($extOther))) {
@@ -715,7 +718,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                                $this->loadTemplate($templateName, $ext);
                        } else {
                                // Throw it again
-                               throw new FileNotFoundException($fqfn, self::EXCEPTION_FILE_NOT_FOUND);
+                               throw new FileNotFoundException($fileInstance, self::EXCEPTION_FILE_NOT_FOUND);
                        }
                }
 
@@ -724,21 +727,21 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        /**
         * A private loader for raw template names
         *
-        * @param       $fqfn   The full-qualified file name for a template
+        * @param       $fileInstance   An instance of a SplFileInfo class
         * @return      void
         */
-       private function loadRawTemplateData ($fqfn) {
+       private function loadRawTemplateData (SplFileInfo $fileInstance) {
                // Some debug code to look on the file which is being loaded
-               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: FQFN=' . $fqfn);
+               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: fileInstance=' . $fileInstance);
 
                // Load the raw template
-               $rawTemplateData = $this->getFileIoInstance()->loadFileContents($fqfn);
+               $rawTemplateData = $this->getFileIoInstance()->loadFileContents($fileInstance);
 
                // Store the template's contents into this class
                $this->setRawTemplateData($rawTemplateData);
 
-               // Remember the template's FQFN
-               $this->setLastTemplate($fqfn);
+               // Remember the template's file instance
+               $this->setLastTemplate($fileInstance);
        }
 
        /**
index 19fc484..e04fd74 100644 (file)
@@ -12,6 +12,7 @@ use CoreFramework\Template\CompileableTemplate;
 use CoreFramework\Template\Engine\BaseTemplateEngine;
 
 // Import SPL stuff
+use \SplFileInfo;
 use \UnexpectedValueException;
 
 /**
@@ -471,13 +472,13 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
        }
 
        /**
-        * Getter for image cache file (FQFN)
+        * Getter for image cache file instance
         *
-        * @return      $fqfn   Full-qualified file name of the image cache
+        * @return      $fileInstance   An instance of a SplFileInfo class
         */
-       public function getImageCacheFqfn () {
-               // Get the FQFN ready
-               $fqfn = sprintf('%s%s%s/%s.%s',
+       public function getImageCacheFile () {
+               // Get the instance ready
+               $fileInstance = new SplFileInfo(sprintf('%s%s%s/%s.%s',
                        $this->getConfigInstance()->getConfigEntry('framework_base_path'),
                        $this->getGenericBasePath(),
                        'images/_cache',
@@ -485,10 +486,10 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
                                $this->getImageInstance()->getImageName() . ':' . $this->__toString() . ':' . $this->getImageInstance()->__toString()
                        ),
                        $this->getImageInstance()->getImageType()
-               );
+               ));
 
                // Return it
-               return $fqfn;
+               return $fileInstance;
        }
 
        /**
index 6fe6f95..4373f49 100644 (file)
@@ -328,21 +328,6 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
        }
 
        /**
-        * Getter for image cache file (FQFN)
-        *
-        * @return      $fqfn   Full-qualified file name of the image cache
-        * @todo        0% done
-        */
-       public function getMailCacheFqfn () {
-               // Initialize FQFN
-               $fqfn = '';
-               $this->debugBackTrace('Unfinished area!');
-
-               // Return it
-               return $fqfn;
-       }
-
-       /**
         * Setter for mailer instance
         *
         * @param       $mailerInstance         A mailer instance
index a0c75eb..d29af28 100644 (file)
@@ -11,6 +11,7 @@ use CoreFramework\Template\CompileableTemplate;
 use CoreFramework\Template\Engine\BaseTemplateEngine;
 
 // Import SPL stuff
+use \SplFileInfo;
 use \UnexpectedValueException;
 
 /**
@@ -865,16 +866,16 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
        }
 
        /**
-        * Getter for menu cache file (FQFN)
+        * Getter for menu cache file instance
         *
-        * @return      $fqfn   Full-qualified file name of the menu cache
+        * @return      $fileInstance   Full-qualified file name of the menu cache
         */
-       public function getMenuCacheFqfn () {
+       public function getMenuCacheFile () {
                // Get the application instance from registry
                $applicationInstance = Registry::getRegistry()->getInstance('app');
 
-               // Get the FQFN ready
-               $fqfn = sprintf('%s%smenus/_cache/%s.%s',
+               // Get the file instance ready
+               $fileInstance = new SplFileInfo(sprintf('%s%smenus/_cache/%s.%s',
                        $this->getConfigInstance()->getConfigEntry('application_base_path'),
                        $applicationInstance->getAppShortName(),
                        md5(
@@ -883,10 +884,10 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                                $this->getMenuInstance()->__toString()
                        ),
                        $this->getMenuInstance()->getMenuType()
-               );
+               ));
 
                // Return it
-               return $fqfn;
+               return $fileInstance;
        }
 
 }
index 9021641..d730677 100644 (file)
@@ -10,6 +10,9 @@ use CoreFramework\Generic\FrameworkException;
 use CoreFramework\Object\BaseFrameworkSystem;
 use CoreFramework\Socket\InvalidSocketException;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * This class contains static helper functions for console applications
  *
@@ -242,9 +245,12 @@ class ConsoleTools extends BaseFrameworkSystem {
                // Get a new instance
                $helperInstance = new ConsoleTools();
 
+               // Get SplFileInfo instance
+               $infoInstance = new SplFileInfo($helperInstance->getConfigInstance()->getConfigEntry('hostname_file'));
+
                try {
                        // Get a file pointer
-                       $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($helperInstance->getConfigInstance()->getConfigEntry('hostname_file')));
+                       $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($infoInstance));
 
                        // Read the file
                        $rawData = trim($fileInstance->readFromFile());
index a445dd7..573c909 100644 (file)
@@ -5,6 +5,9 @@ namespace CoreFramework\Filesystem;
 // Import framework stuff
 use CoreFramework\Generic\FrameworkException;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * An exception thrown when a file pointer is not opened or when the file
  * cannot be reached.
@@ -32,13 +35,13 @@ class FileIoException extends FrameworkException {
        /**
         * The constructor
         *
-        * @param       $fqfn   Full-qualified file name of (maybe) missing file
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @param       $code   Code number for the exception
         * @return      void
         */
-       public function __construct ($fqfn, $code) {
+       public function __construct (SplFileInfo $infoInstance, $code) {
                // Add a message around the missing class
-               $message = sprintf('A problem has been detected reading or writing to/from %s.', $fqfn);
+               $message = sprintf('A problem has been detected reading or writing to/from %s.', $infoInstance->getPathname());
 
                // Call parent constructor
                parent::__construct($message, $code);
index a44be02..55fe201 100644 (file)
@@ -5,6 +5,9 @@ namespace CoreFramework\Deprecated;
 // Import framework stuff
 use CoreFramework\Generic\FrameworkException;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * An exception thrown when a file name is empty or NULL.
  *
@@ -32,11 +35,11 @@ class FileIsEmptyException extends FrameworkException {
        /**
         * The constructor
         *
-        * @param       $fqfn   Ignored
+        * @param       $infoInstance   An instance of a SplFileInfo class (ignored)
         * @param       $code   Code number for the exception
         * @return      void
         */
-       public function __construct ($fqfn, $code) {
+       public function __construct (SplFileInfo $infoInstance, $code) {
                // Call parent constructor
                parent::__construct('No file name provided.', $code);
        }
index e86ee27..76718a0 100644 (file)
@@ -5,6 +5,9 @@ namespace CoreFramework\Filesystem;
 // Import framework stuff
 use CoreFramework\Generic\FrameworkException;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * An exception thrown when a file was not found (but could be found).
  *
@@ -31,13 +34,13 @@ class FileNotFoundException extends FrameworkException {
        /**
         * The constructor
         *
-        * @param       $fqfn   Full-qualified file name of (maybe) missing file
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @param       $code   Code number for the exception
         * @return      void
         */
-       public function __construct ($fqfn, $code) {
+       public function __construct (SplFileInfo $infoInstance, $code) {
                // Add a message around the missing class
-               $message = sprintf('File %s not found.', $fqfn);
+               $message = sprintf('File "%s" not found.', $infoInstance->getPathname());
 
                // Call parent constructor
                parent::__construct($message, $code);
index 7be7ba6..039e1bd 100644 (file)
@@ -5,6 +5,9 @@ namespace CoreFramework\FileSystem;
 // Import framework stuff
 use CoreFramework\Generic\FrameworkException;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * An exception thrown when a file is read-protected
  *
@@ -31,13 +34,13 @@ class FileReadProtectedException extends FrameworkException {
        /**
         * The constructor
         *
-        * @param       $fileName       File which cannot be read from
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @param       $code           Code number for the exception
         * @return      void
         */
-       public function __construct ($fileName, $code) {
+       public function __construct (SplFileInfo $infoInstance, $code) {
                // Add a message around the missing class
-               $message = sprintf('File %s is read-protected. Please set read access rights (CHMOD).', $fileName);
+               $message = sprintf('File %s is read-protected. Please set read access rights (CHMOD).', $infoInstance->getPathname());
 
                // Call parent constructor
                parent::__construct($message, $code);
index 71edcf0..a0de731 100644 (file)
@@ -5,6 +5,9 @@ namespace CoreFramework\FileSystem;
 // Import framework stuff
 use CoreFramework\Generic\FrameworkException;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * An exception thrown when a file could not be written.
  *
@@ -31,13 +34,13 @@ class FileWriteProtectedException extends FrameworkException {
        /**
         * The constructor
         *
-        * @param       $fqfn   Full-qualified file name of (maybe) missing file
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @param       $code   Code number for the exception
         * @return      void
         */
-       public function __construct ($fqfn, $code) {
+       public function __construct (SplFileInfo $infoInstance, $code) {
                // Add a message around the missing class
-               $message = sprintf('File %s cannot be written. Please check file and/or directory permissions.', $fqfn);
+               $message = sprintf('File %s cannot be written. Please check file and/or directory permissions.', $infoInstance->getPathname());
 
                // Call parent constructor
                parent::__construct($message, $code);
index 13ae3da..2e4da83 100644 (file)
@@ -6,6 +6,9 @@ namespace CoreFramework\Filesystem;
 use CoreFramework\Filesystem\PathWriteProtectedException;
 use CoreFramework\Generic\FrameworkException;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * An exception thrown when a path cannot be written to.
  *
@@ -32,13 +35,13 @@ class PathWriteProtectedException extends FrameworkException {
        /**
         * The constructor
         *
-        * @param       $fqfn   Full-qualified file name
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @param       $code   Code number for the exception
         * @return      void
         */
-       public function __construct ($fqfn, $code) {
+       public function __construct (SplFileInfo $infoInstance, $code) {
                // Add a message around the missing class
-               $message = sprintf('Path %s cannot be written to. Please check permissions.', dirname($fqfn));
+               $message = sprintf('Path "%s" cannot be written to. Please check permissions.', $infoInstance->getPath());
 
                // Call parent constructor
                parent::__construct($message, $code);
index 882714b..7057fc8 100644 (file)
@@ -50,13 +50,6 @@ interface Block extends FrameworkInterface {
        function isEndOfFileReached ();
 
        /**
-        * Getter for file name
-        *
-        * @return      $fileName       The current file name
-        */
-       function getFileName ();
-
-       /**
         * Initializes counter for valid entries, arrays for damaged entries and
         * an array for gap seek positions. If you call this method on your own,
         * please re-analyze the file structure. So you are better to call
index f028738..c30e8c3 100644 (file)
@@ -29,18 +29,11 @@ use CoreFramework\Generic\FrameworkInterface;
  */
 interface FilePointer extends FrameworkInterface {
        /**
-        * Getter for the file pointer
+        * Getter for the file object
         *
-        * @return      $filePointer    The file pointer which shall be a valid file resource
+        * @return      $fileObject             An instance of a SplFileObject class
         */
-       function getPointer ();
-
-       /**
-        * Getter for file name
-        *
-        * @return      $fileName       The current file name
-        */
-       function getFileName ();
+       function getFileObject ();
 
        /**
         * Determines whether the EOF has been reached
index 25ed295..18dd895 100644 (file)
@@ -5,6 +5,9 @@ namespace CoreFramework\Stream\Filesystem;
 // Import framework stuff
 use CoreFramework\Stream\Input\StreamableInput;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * An interface for file input operations.
  *
@@ -28,14 +31,15 @@ use CoreFramework\Stream\Input\StreamableInput;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface FileInputStreamer extends StreamableInput {
+
        /**
         * Reads from a local or remote file
         *
-        * @param       $fqfn   The file's FQFN we shall load
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @return      $array  An array containing all read lines
         * @throws      InvalidArrayCountException      If an array has not the expected size
         * @throws      InvalidMD5ChecksumException     If two MD5 hashes did not match
         */
-       function loadFileContents ($fqfn);
+       function loadFileContents (SplFileInfo $infoInstance);
 
 }
index 158d0c5..5de8fd4 100644 (file)
@@ -5,6 +5,9 @@ namespace CoreFramework\Stream\Filesystem;
 // Import framework stuff
 use CoreFramework\Stream\Output\StreamableOutput;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * An interface for file output operations.
  *
@@ -28,14 +31,15 @@ use CoreFramework\Stream\Output\StreamableOutput;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface FileOutputStreamer extends StreamableOutput {
+
        /**
         * Saves streamed (that are mostly serialized objects) data to files or
         * external servers.
         *
-        * @param       $fileName                       The local file's name including full path
-        * @param       $dataArray                      Array containing the compressor's extension and streamed data
+        * @param       $infoInstance   An instance of a SplFileInfo class
+        * @param       $dataArray              Array containing the compressor's extension and streamed data
         * @return      void
         */
-       function saveFile ($fileName, array $dataArray);
+       function saveFile (SplFileInfo $infoInstance, array $dataArray);
 
 }
index 1c90ae8..0ed7f01 100644 (file)
@@ -7,6 +7,9 @@ use CoreFramework\Generic\FrameworkInterface;
 use CoreFramework\Stream\Filesystem\FileInputStreamer;
 use CoreFramework\Stream\Filesystem\FileOutputStreamer;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * An interface for I/O handlers
  *
@@ -30,6 +33,7 @@ use CoreFramework\Stream\Filesystem\FileOutputStreamer;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface IoHandler extends FileInputStreamer, FileOutputStreamer {
+
        /**
         * Setter for the *real* file input instance
         *
@@ -63,11 +67,11 @@ interface IoHandler extends FileInputStreamer, FileOutputStreamer {
        /**
         * Saves a file with data by using the current output stream
         *
-        * @param       $fileName                       Name of the file
+        * @param       $infoInstance           An instance of a SplFileInfo class
         * @param       $dataStream                     File data stream
         * @param       $objectInstance         An instance of a FrameworkInterface class (default: NULL)
         * @return      void
         */
-       function saveStreamToFile ($fileName, $dataStream, FrameworkInterface $objectInstance = NULL);
+       function saveStreamToFile (SplFileInfo $infoInstance, $dataStream, FrameworkInterface $objectInstance = NULL);
 
 }
index 0682e03..2277130 100644 (file)
@@ -11,6 +11,9 @@ use CoreFramework\Middleware\BaseMiddleware;
 use CoreFramework\Stream\Filesystem\FileInputStreamer;
 use CoreFramework\Stream\Filesystem\FileOutputStreamer;
 
+// Import SPL stuff
+use \SplFileInfo;
+
 /**
  * This is a file IO handler. It handles reading from and writing to files.
  * Missing paths in writing process will be automatically created.
@@ -131,25 +134,25 @@ class FileIoHandler extends BaseMiddleware implements IoHandler {
         * Saves streamed (that are mostly serialized objects) data to files or
         * external servers.
         *
-        * @param       $fileName       The local file's name including full path
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @param       $dataArray      Array containing the compressor's extension and streamed data
         * @return      void
         * @throws      UnsupportedOperationException   If this method is called
         */
-       public function saveFile ($fileName, array $dataArray) {
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('fileName=' . $fileName . ',dataArray()=' . count($dataArray));
+       public function saveFile (SplFileInfo $infoInstance, array $dataArray) {
+               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('infoInstance.pathname=' . $infoInstance->getPathname() . ',dataArray()=' . count($dataArray));
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
        /**
         * Saves a file with data by using the current output stream
         *
-        * @param       $fileName                       Name of the file
+        * @param       $infoInstance           An instance of a SplFileInfo class
         * @param       $dataStream                     File data stream
         * @param       $objectInstance         An instance of a FrameworkInterface class (default: NULL)
         * @return      void
         */
-       public function saveStreamToFile ($fileName, $dataStream, FrameworkInterface $objectInstance = NULL) {
+       public function saveStreamToFile (SplFileInfo $infoInstance, $dataStream, FrameworkInterface $objectInstance = NULL) {
                // Default is this array
                $className = $this->__toString();
 
@@ -165,18 +168,18 @@ class FileIoHandler extends BaseMiddleware implements IoHandler {
                        1 => $dataStream
                );
 
-               // Send the fileName and dataArray to the output handler
-               $this->getOutputStream()->saveFile($fileName, $dataArray);
+               // Send the infoInstance and dataArray to the output handler
+               $this->getOutputStream()->saveFile($infoInstance, $dataArray);
        }
 
        /** Loads data from a file over the input handler
         *
-        * @param       $fqfn   Given full-qualified file name (FQFN) to load
+        * @param       $infoInstance   An instance of a SplFileInfo class
         * @return      $array  Array with the file contents
         */
-       public function loadFileContents ($fqfn) {
+       public function loadFileContents (SplFileInfo $infoInstance) {
                // Read from the input handler
-               return $this->getInputStream()->loadFileContents($fqfn);
+               return $this->getInputStream()->loadFileContents($infoInstance);
        }
 
        /**