Exemple #1
0
 /**
  * Get the contents of this entry.
  *
  * @throws Exception Throws an Exception in case of errors.
  *
  * @return string
  */
 public function getContents()
 {
     $cacheEnabled = static::getContentCacheEnabled();
     if ($cacheEnabled && $this->cachedContents !== null) {
         $result = $this->cachedContents;
     } else {
         $section = $this->chm->getSectionByIndex($this->contentSectionIndex);
         if ($section === null) {
             throw new Exception("The CHM file does not contain a data section with index {$this->contentSectionIndex}");
         }
         $result = $section->getContents($this->offset, $this->length);
         $this->cachedContents = $cacheEnabled ? $result : null;
     }
     return $result;
 }
Exemple #2
0
 /**
  * Search the associated entry in the CHM file.
  *
  * @return \CHMLib\Entry|null
  */
 public function findEntry()
 {
     $result = null;
     if ($this->local !== '') {
         $path = '/' . ltrim(str_replace('\\', '/', $this->local), '/');
         $entry = $this->chm->getEntryByPath($path);
         if ($entry === null) {
             $p = strpos($path, '#');
             if ($p !== false) {
                 $path = substr($path, 0, $p);
                 $entry = $this->chm->getEntryByPath($path);
             }
         }
         if ($entry !== null && $entry->isFile()) {
             $result = $entry;
         }
     }
     return $result;
 }