/** * Writes the data size to the header and a CRC checksum at the end. * @return \Fit\Writer */ protected function writeFileClosure() { //mark current writing position $offset = $this->writer->getOffset(); //move to header and write the size of the data $this->writer->setOffset(4); $data_size = $this->writer->getSize() - 14; $this->writer->writeUInt32LE($data_size); // Does not include file header or crc. Little endian format. //write 2 byte crc check at end of file $this->writer->setOffset($offset); $this->writer->writeUInt16LE(0); return $this; }