Esempio n. 1
0
 /**
  * Read header from bnp file
  */
 private function initialize()
 {
     if ($this->header !== false) {
         return;
     }
     $this->bnp = fopen($this->filename, 'r');
     $stats = fstat($this->bnp);
     $size = $stats['size'];
     $s = new MemStream();
     // read last <int> to get position for FAT block
     fseek($this->bnp, $size - 4);
     $buf = fread($this->bnp, 4);
     $s->setBuffer($buf);
     $s->serial_uint32($pos);
     // now read FAT block
     fseek($this->bnp, $pos);
     $fat = fread($this->bnp, $size - $pos);
     $s->setBuffer($fat);
     $s->serial_uint32($nbFiles);
     $this->header = array();
     for ($i = 0; $i < $nbFiles; $i++) {
         $s->serial_byte_string($name);
         $s->serial_uint32($size);
         $s->serial_uint32($start);
         $this->header[$name] = array('size' => $size, 'start' => $start);
     }
     $this->headerCount = count($this->header);
     $this->headerFiles = array_keys($this->header);
     $this->headerPosition = 0;
 }