From: Roland Haeder Date: Fri, 16 May 2014 22:45:58 +0000 (+0200) Subject: Continued with file i/o: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=869f4d32219899f678c27272b5a4ea59fc48f362;p=core.git Continued with file i/o: - added saveStreamToFile() to IoHandler - added saveFile() as unsupported method to FileIoHandler Signed-off-by: Roland Häder --- diff --git a/inc/classes/interfaces/io/file/handler/class_IoHandler.php b/inc/classes/interfaces/io/file/handler/class_IoHandler.php index 0463b826..12e1049f 100644 --- a/inc/classes/interfaces/io/file/handler/class_IoHandler.php +++ b/inc/classes/interfaces/io/file/handler/class_IoHandler.php @@ -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] diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php index dd1f5b74..16e6bee0 100644 --- a/inc/classes/main/database/databases/class_LocalFileDatabase.php +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -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.'); diff --git a/inc/classes/middleware/io/class_FileIoHandler.php b/inc/classes/middleware/io/class_FileIoHandler.php index 81be5056..8e5559b0 100644 --- a/inc/classes/middleware/io/class_FileIoHandler.php +++ b/inc/classes/middleware/io/class_FileIoHandler.php @@ -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();