Continued with file-based hash:
[core.git] / inc / classes / main / iterator / io / class_FileIoIterator.php
index 03c0c25b2f81747e00e17c6c4f422af2a8e58cd5..0dceb7ab31bb6b8725a8662e0170770d764b4727 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class FileIoIterator extends BaseIterator implements SeekableWritableFileIterator {
-       /**
-        * Current absolute seek position (returned by key())
-        */
-       private $seekPosition = FALSE;
-
-       /**
-        * Total entries (read from file)
-        */
-       private $totalEntriesFile = FALSE;
-
        /**
         * Protected constructor
         *
@@ -80,13 +70,8 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato
         * @return      $key    Current key in iteration
         */
        public function key () {
-               // Default is null
-               $key = null;
-
-               $this->partialStub('Please implement this method.');
-
                // Return it
-               return $key;
+               return $this->getPointerInstance()->getSeekPosition();
        }
 
        /**
@@ -104,7 +89,8 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato
         * @return      void
         */
        public function rewind () {
-               $this->partialStub('Please implement this method.');
+               // Call pointer instance
+               $this->getPointerInstance()->rewind();
        }
 
        /**
@@ -113,8 +99,24 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato
         * @param       $seekPosition   Seek position in file
         * @return      void
         */
-       public function seek ($seedPosition) {
-               $this->partialStub('Please implement this method. seekPosition=' . $seekPosition);
+       public function seek ($seekPosition) {
+               // Call pointer instance
+               $this->getPointerInstance()->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 ($seedPosition, $data) {
+               // First seek to it
+               $this->seek($seekPosition);
+
+               // Then write the data at that position
+               $this->getPointerInstance()->writeToFile($data);
        }
 
        /**