private function traveller($directory, Intent $intent = null) { if (!($dirOpen = opendir($directory))) { return false; } $files = []; while ($fileName = readdir($dirOpen)) { if ($fileName === "." || $fileName === "..") { continue; } $fileIns = new File($directory . "/" . $fileName); if ($fileIns->isDirectory() === true && $fileIns->isReadable() === true) { $this->traveller($fileIns->getPath(), $intent); $this->callback->onCallback(pathinfo($fileIns->getPath()), $intent); } elseif ($fileIns->isFile()) { if ($this->mode == self::MODE_SAMETIME) { $this->callback->onCallback(pathinfo($fileIns->getPath()), $intent); } elseif ($this->mode == self::MODE_SEPERATE_FILES) { $this->files[] = $fileIns; continue; } elseif ($fileIns->isReadable() === false) { $this->errorStack->putError(self::TAG, self::ERROR_CANNOT_BE_READ); } } } closedir($dirOpen); return true; }
function makeCacheFromFile($filePath, $externalContent = null, $fileNotExists) { $file = new File($filePath); if ((!$file->isFile() || !$file->isReadable()) && $fileNotExists == false) { return false; } $cacheFile = new File($this->convertFileName($file->getPath())); if ($cacheFile->doesExist()) { return false; } $cacheFile->createNewFile(); if (!$cacheFile->isWritable()) { return false; } if ($externalContent !== null) { return $cacheFile->putIndex($externalContent); } else { return $cacheFile->putIndex($file->getIndex()); } }
public function getParLibraryIndex($fileName) { $parFile = new File($fileName); if (!$parFile->isFile()) { return false; } $Zip = new ZipArchive(); if (!$Zip->open($fileName)) { return false; } for ($i = 0; $i < $Zip->numFiles; $i++) { $Name = $Zip->statIndex($i)['name']; if (substr($Name, -1) == "/") { continue; } $filesArray[$Name] = $i; } $this->getCache()->makeCacheFromFile($parFile->getPath(), json_encode($filesArray)); return true; }