writeAtPosition() also belongs in OutputPointer classes.
authorRoland Haeder <roland@mxchange.org>
Mon, 23 Jun 2014 21:15:24 +0000 (23:15 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 23 Jun 2014 21:15:24 +0000 (23:15 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
inc/classes/interfaces/io/pointer/class_OutputPointer.php
inc/classes/interfaces/iterator/class_SeekableWritableFileIterator.php
inc/classes/main/file_directories/io/class_FrameworkFileInputOutputPointer.php
inc/classes/main/index/class_BaseIndex.php
inc/classes/main/iterator/file/class_FileIterator.php
inc/classes/main/stacker/file/class_BaseFileStack.php

index 06c5835fa836f49279d3d56e715b8f3adc0e16a6..472bba55cbef715f77f23e1863a57cf70dc7d6bb 100644 (file)
@@ -33,6 +33,15 @@ interface OutputPointer extends StreamableOutput, Pointer {
         *                                                                                      an invalid file resource
         */
        function writeToFile ($dataStream);
         *                                                                                      an invalid file resource
         */
        function writeToFile ($dataStream);
+
+       /**
+        * Writes at given position by seeking to it.
+        *
+        * @param       $seekPosition   Seek position in file
+        * @param       $data                   Data to be written
+        * @return      mixed                   Number of writes bytes or FALSE on error
+        */
+       function writeAtPosition ($seedPosition, $data);
 }
 
 // [EOF]
 }
 
 // [EOF]
index 3bb0d8160c6ee60f6833e68854fa57102641e3fc..12df16c80f1eac60599d749235c0620d1075ccdc 100644 (file)
@@ -38,15 +38,6 @@ interface SeekableWritableFileIterator extends SeekableIterator {
         */
        function size ();
 
         */
        function size ();
 
-       /**
-        * Writes at given position by seeking to it.
-        *
-        * @param       $seekPosition   Seek position in file
-        * @param       $data                   Data to be written
-        * @return      void
-        */
-       function writeAtPosition ($seedPosition, $data);
-
        /**
         * Reads given amount of bytes from file.
         *
        /**
         * Reads given amount of bytes from file.
         *
index fb1762ad437c8f954037700ad4671773b715f5fd..05d064d8de3a670e6f686f5f9d08f49bdf9838a2 100644 (file)
@@ -124,6 +124,21 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                return fwrite($this->getPointer(), $dataStream, strlen($dataStream));
        }
 
                return fwrite($this->getPointer(), $dataStream, strlen($dataStream));
        }
 
+       /**
+        * Writes at given position by seeking to it.
+        *
+        * @param       $seekPosition   Seek position in file
+        * @param       $data                   Data to be written
+        * @return      mixed                   Number of writes bytes or FALSE on error
+        */
+       public function writeAtPosition ($seekPosition, $data) {
+               // First seek to it
+               $this->seek($seekPosition);
+
+               // Then write the data at that position
+               return $this->getBlockInstance()->writeToFile($data);
+       }
+
        /**
         * Rewinds to the beginning of the file
         *
        /**
         * Rewinds to the beginning of the file
         *
index 9e001be7706178967f2e726178c5d88441ed1baf..b2977c6838e296096984e8d401f8ab9ab940707c 100644 (file)
@@ -122,7 +122,7 @@ class BaseIndex extends BaseFrameworkSystem {
                );
 
                // Write it to disk (header is always at seek position 0)
                );
 
                // Write it to disk (header is always at seek position 0)
-               $this->writeData(0, $header, FALSE);
+               $this->getIteratorInstance()->writeData(0, $header, FALSE);
 
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
        }
 
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
        }
index e73360746691268788d78cd90610ab29847ef394..f8fadbde41e3ab1ea5de5dcfc04c4014214a8a48 100644 (file)
@@ -112,21 +112,6 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                return $this->getBlockInstance()->seek($seekPosition);
        }
 
                return $this->getBlockInstance()->seek($seekPosition);
        }
 
-       /**
-        * Writes at given position by seeking to it.
-        *
-        * @param       $seekPosition   Seek position in file
-        * @param       $data                   Data to be written
-        * @return      void
-        */
-       public function writeAtPosition ($seekPosition, $data) {
-               // First seek to it
-               $this->seek($seekPosition);
-
-               // Then write the data at that position
-               $this->getBlockInstance()->writeToFile($data);
-       }
-
        /**
         * Size of file stack
         *
        /**
         * Size of file stack
         *
index d225950b0b2464186a9b7fad5cff6e3def9c6c35..8c518b4fef4df6d8585e0ebb82fbd1abd772bd01 100644 (file)
@@ -126,14 +126,14 @@ class BaseFileStack extends BaseStacker {
                        chr(BaseBinaryFile::SEPARATOR_HEADER_DATA),
 
                        // Position (will be zero)
                        chr(BaseBinaryFile::SEPARATOR_HEADER_DATA),
 
                        // Position (will be zero)
-                       str_pad($this->dec2hex($this->getSeekPosition(), 2), BaseBinaryFile::LENGTH_POSITION, '0', STR_PAD_LEFT),
+                       str_pad($this->dec2hex($this->getIteratorInstance()->getSeekPosition(), 2), BaseBinaryFile::LENGTH_POSITION, '0', STR_PAD_LEFT),
 
                        // Separator position<->entries
                        chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES)
                );
 
                // Write it to disk (header is always at seek position 0)
 
                        // Separator position<->entries
                        chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES)
                );
 
                // Write it to disk (header is always at seek position 0)
-               $this->writeData(0, $header, FALSE);
+               $this->getIteratorInstance()->writeData(0, $header, FALSE);
 
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
        }
 
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
        }