/** * Unpack PHAR archive * * @param string $file File path * @param string $dir Dir to extract to * * @return string */ public static function unpack($file, $dir) { $dir = \Includes\Utils\FileManager::getCanonicalDir($dir) . pathinfo($file, PATHINFO_FILENAME); try { $phar = new \PharData($file); $result = $phar->extractTo($dir, null, true); } catch (\Exception $exception) { $result = false; \XLite\Upgrade\Logger::getInstance()->logError($exception->getMessage()); } return array($dir, $result); }
/** * Wrapper for the abstract method * * @param mixed $getFullPath Flag OPTIONAL * * @return string */ protected function getUpgradeHelpersDir($getFullPath = true) { $path = \Includes\Utils\FileManager::getCanonicalDir($this->getRepositoryPath()); if (!empty($path)) { $dir = $this->getUpgradeHelperPath() . 'upgrade' . LC_DS; } return \Includes\Utils\FileManager::isDir($path . $dir) ? ($getFullPath ? $path : '') . $dir : null; }
/** * Constructor * * @param string $dir Directory to iterate over * @param string $pattern Pattern to filter files * @param int $mode Filtering mode OPTIONAL * * @return void */ public function __construct($dir, $pattern = null, $mode = \RecursiveIteratorIterator::LEAVES_ONLY) { $canonicalDir = \Includes\Utils\FileManager::getCanonicalDir($dir); if (empty($canonicalDir)) { \Includes\ErrorHandler::fireError('Path "' . $dir . '" is not exists or is not readable.'); } $this->dir = $canonicalDir; $this->pattern = $pattern; $this->mode = $mode; }