Esempio n. 1
0
 /**
  * Internal constructor, called from loadFromFile and createNew.
  * @param   string  $filePath
  * @throws  \Exception
  */
 protected function __construct($filePath = '')
 {
     if ($filePath !== '') {
         $this->isFromFile = true;
         parent::__construct($filePath);
         if ($this->fileSize < 76) {
             throw new \Exception("This file is not a valid TI-[e]z80 variable file");
         }
         $this->makeHeaderFromFile();
         $this->makeVarEntryFromFile();
         $this->computedChecksum = $this->computeChecksumFromFileData();
         $this->inFileChecksum = $this->getChecksumValueFromFile();
         $this->type = TIVarType::createFromID($this->varEntry['typeID']);
     } else {
         $this->isFromFile = false;
     }
 }
Esempio n. 2
0
 /**
  * Internal constructor, called from loadFromFile and createNew.
  * @param   string  $filePath
  * @throws  \Exception
  */
 protected function __construct($filePath = '')
 {
     if ($filePath !== '') {
         $this->isFromFile = true;
         parent::__construct($filePath);
         if ($this->fileSize < 76) {
             throw new \RuntimeException('This file is not a valid TI-[e]z80 variable file');
         }
         $this->makeHeaderFromFile();
         $this->makeVarEntryFromFile();
         $this->computedChecksum = $this->computeChecksumFromFileData();
         $this->inFileChecksum = $this->getChecksumValueFromFile();
         if ($this->computedChecksum !== $this->inFileChecksum) {
             //echo "[Warning] File is corrupt (read and calculated checksums differ)\n";
             $this->corrupt = true;
         }
         $this->type = TIVarType::createFromID($this->varEntry['typeID']);
     } else {
         $this->isFromFile = false;
     }
 }