// Simple flush file header which will create it.
$this->flushFileHeader();
+ // Seek to beginning of file
+ $this->getIteratorInstance()->rewind();
+
+ // And update seek position ...
+ $this->updateSeekPosition();
+
+ // ... to write it back into the file
+ $this->flushFileHeader();
+
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!!', __METHOD__, __LINE__));
}
+ /**
+ * Seeks to old position
+ *
+ * @return void
+ */
+ protected function seekToOldPosition () {
+ // Seek to currently ("old") saved position
+ $this->getIteratorInstance()->seek($this->getSeekPosition());
+ }
+
/**
* Writes data at given position
*
* @param $seekPosition Seek position
* @param $data Data to be written
+ * @param $flushHeader Whether to flush the header (default: flush)
* @return void
*/
- protected function writeData ($seekPosition, $data) {
+ protected function writeData ($seekPosition, $data, $flushHeader = TRUE) {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s,data()=%s - CALLED!', __METHOD__, __LINE__, $seekPosition, strlen($data)));
// Write data at given position
// Update seek position
$this->updateSeekPosition();
- // Flush header
- $this->flushFileHeader();
+ // Flush the header?
+ if ($flushHeader === TRUE) {
+ // Flush header
+ $this->flushFileHeader();
+ } // END - if
// Seek to old position
$this->seekToOldPosition();