+ /**
+ * Reads the file header
+ *
+ * @return void
+ */
+ private function readFileHeader () {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
+
+ // First rewind to beginning as the header sits at the beginning ...
+ $this->getIteratorInstance()->rewind();
+
+ // Then read it (see constructor for calculation)
+ $data = $this->getIteratorInstance()->read($this->headerLength);
+
+ // Last character must be the separator
+ assert(substr($data, -1, 1) == self::SEPARATOR_HEADER_ENTRIES);
+
+ // Okay, then remove it
+ $data = substr($data, 0, -1);
+
+ // And update seek position
+ $this->updateSeekPosition();
+
+ /*
+ * Now split it:
+ *
+ * 0 => Magic
+ * 1 => Total entries
+ * 2 => Current seek position
+ */
+ $this->header = explode(self::SEPARATOR_HEADER_DATA, $data);
+
+ // Check if the array has only 3 elements
+ assert(count($this->header) == 3);
+
+ // Check magic
+ assert($this->header[0] == self::MAGIC);
+
+ // Check length of count and seek position
+ assert(strlen($this->header[1]) == self::LENGTH_COUNT);
+ assert(strlen($this->header[2]) == self::LENGTH_POSITION);
+
+ // Decode count and seek position
+ $this->header[1] = hex2bin($this->header[1]);
+ $this->header[2] = hex2bin($this->header[2]);
+
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
+ }
+