]> git.mxchange.org Git - core.git/commitdiff
Continued with file i/o:
authorRoland Haeder <roland@mxchange.org>
Fri, 16 May 2014 22:45:58 +0000 (00:45 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 16 May 2014 22:45:58 +0000 (00:45 +0200)
- added saveStreamToFile() to IoHandler
- added saveFile() as unsupported method to FileIoHandler

Signed-off-by: Roland Häder <roland@mxchange.org>
inc/classes/interfaces/io/file/handler/class_IoHandler.php
inc/classes/main/database/databases/class_LocalFileDatabase.php
inc/classes/middleware/io/class_FileIoHandler.php

index 0463b826f5cf4bc31d03661f52ace638c47c90cd..12e1049f20eb05b407d92ec1a50275d113fdbd0b 100644 (file)
@@ -51,6 +51,16 @@ interface IoHandler extends FileInputStreamer, FileOutputStreamer {
         * @return      $outputStream   The *real* file-output class
         */
        function getOutputStream ();
+
+       /**
+        * Saves a file with data by using the current output stream
+        *
+        * @param       $fileName                       Name of the file
+        * @param       $dataStream                     File data stream
+        * @param       $objectInstance         An instance of a FrameworkInterface class (default: NULL)
+        * @return      void
+        */
+       function saveStreamToFile ($fileName, $dataStream, FrameworkInterface $objectInstance = NULL);
 }
 
 // [EOF]
index dd1f5b745990c5d6d90f148a913626948ccead42..16e6bee0047b3c1e01de9a23b6b5ab3be1c444aa 100644 (file)
@@ -206,7 +206,7 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Writing ' . strlen($compressedData) . ' bytes ...');
 
                // Write this data BASE64 encoded to the file
-               $this->getFileIoInstance()->saveFile($fqfn, $compressedData, $this);
+               $this->getFileIoInstance()->saveStreamToFile($fqfn, $compressedData, $this);
 
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file completed.');
index 81be505619114f92fca24ee1237d1a2f8f30ef25..8e5559b065a8abf510d3dc9dc960e5972ff758fe 100644 (file)
@@ -115,6 +115,19 @@ class FileIoHandler extends BaseMiddleware implements IoHandler {
        public final function getOutputStream () {
                return $this->outputStream;
        }
+       /**
+        * 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
+        * @return      void
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function saveFile ($fileName, array $dataArray) {
+               self::createDebugInstance(__CLASS__)->debugOutput('fileName=' . $fileName . ',dataArray()=' . count($dataArray));
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
 
        /**
         * Saves a file with data by using the current output stream
@@ -124,7 +137,7 @@ class FileIoHandler extends BaseMiddleware implements IoHandler {
         * @param       $objectInstance         An instance of a FrameworkInterface class (default: NULL)
         * @return      void
         */
-       public function saveFile ($fileName, $dataStream, FrameworkInterface $objectInstance = NULL) {
+       public function saveStreamToFile ($fileName, $dataStream, FrameworkInterface $objectInstance = NULL) {
                // Default is this array
                $className = $this->__toString();