XBase\Table::readHeader PHP Method

readHeader() protected method

protected readHeader ( )
    protected function readHeader()
    {
        $this->version = $this->readChar();
        $this->foxpro = in_array($this->version, array(48, 49, 245, 251, 131, 203, 245));
        $this->modifyDate = $this->read3ByteDate();
        $this->recordCount = $this->readInt();
        $this->headerLength = $this->readShort();
        $this->recordByteLength = $this->readShort();
        $this->readBytes(2);
        //reserved
        $this->inTransaction = $this->readByte() != 0;
        $this->encrypted = $this->readByte() != 0;
        $this->readBytes(4);
        //Free record thread
        $this->readBytes(8);
        //Reserved for multi-user dBASE
        $this->mdxFlag = $this->readByte();
        $this->languageCode = $this->readByte();
        $this->readBytes(2);
        //reserved
        $fieldCount = floor(($this->headerLength - ($this->foxpro ? 296 : 33)) / 32);
        /* some checking */
        if ($this->headerLength > filesize($this->tableName)) {
            throw new Exception\TableException(sprintf('File %s is not DBF', $this->tableName));
        }
        if ($this->headerLength + $this->recordCount * $this->recordByteLength - 500 > filesize($this->tableName)) {
            throw new Exception\TableException(sprintf('File %s is not DBF', $this->tableName));
        }
        /* columns */
        $this->columns = array();
        $bytepos = 1;
        $j = 0;
        for ($i = 0; $i < $fieldCount; $i++) {
            $column = new Column(strtolower($this->readString(11)), $this->readByte(), $this->readInt(), $this->readChar(), $this->readChar(), $this->readBytes(2), $this->readChar(), $this->readBytes(2), $this->readByte() != 0, $this->readBytes(7), $this->readByte() != 0, $j, $bytepos);
            $bytepos += $column->getLength();
            if (!$this->avaliableColumns || $this->avaliableColumns && in_array($column->name, $this->avaliableColumns)) {
                $this->addColumn($column);
                $j++;
            }
        }
        if ($this->foxpro) {
            $this->backlist = $this->readBytes(263);
        }
        $this->setFilePos($this->headerLength);
        $this->recordPos = -1;
        $this->record = false;
        $this->deleteCount = 0;
    }