* 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
*
* @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();
}
/**
* @return void
*/
public function rewind () {
- $this->partialStub('Please implement this method.');
+ // Call pointer instance
+ $this->getPointerInstance()->rewind();
}
/**
* @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);
}
/**