function __construct($path, $readonly = false) { $this->readonly = $readonly; if (!file_exists($path . '/.registry') && basename($path) !== 'php') { $path = $path . DIRECTORY_SEPARATOR . 'php'; } $this->path = $path; if (isset(\Pyrus\Main::$options['packagingroot'])) { $path = \Pyrus\Main::prepend(\Pyrus\Main::$options['packagingroot'], $path); } $this->_channelPath = $path . DIRECTORY_SEPARATOR . '.channels'; $this->_aliasPath = $this->_channelPath . DIRECTORY_SEPARATOR . '.alias'; if (!file_exists($this->_channelPath) || !is_dir($this->_channelPath)) { if ($readonly) { throw new Exception('Cannot initialize PEAR1 channel registry, directory' . ' does not exist and registry is read-only'); } if (!@mkdir($this->_channelPath, 0755, true)) { throw new Exception('Cannot initialize PEAR1 channel registry, channel' . ' directory could not be initialized'); } } if (!file_exists($this->_aliasPath) || !is_dir($this->_aliasPath)) { if ($readonly) { throw new Exception('Cannot initialize PEAR1 channel registry, aliasdirectory ' . 'does not exist and registry is read-only'); } if (!@mkdir($this->_aliasPath, 0755, true)) { throw new Exception('Cannot initialize PEAR1 channel registry, channel ' . 'aliasdirectory could not be initialized'); } } if (1 === $this->exists('pear.php.net')) { $this->initialized = false; } else { $this->initialized = true; } }
/** * Initialize the registry * * @param string $path */ function __construct($path, $readonly = false) { $this->readonly = $readonly; if (isset(Main::$options['packagingroot'])) { $path = Main::prepend(Main::$options['packagingroot'], $path); } $this->path = $path; $this->channelpath = $path . DIRECTORY_SEPARATOR . '.xmlregistry' . DIRECTORY_SEPARATOR . 'channels'; if (1 === $this->exists('pear.php.net')) { $this->initialized = false; } else { $this->initialized = true; } }
private static function _init($path, $readonly) { if (!$path) { $path = ':memory:'; } else { $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); } if (static::existsRegistry($path)) { return; } $dbpath = $path; if ($path != ':memory:' && isset(Main::$options['packagingroot'])) { $dbpath = Main::prepend(Main::$options['packagingroot'], $path); } if ($path != ':memory:' && !file_exists(dirname($dbpath))) { if ($readonly) { throw new Exception('Cannot create SQLite3 registry, registry is read-only'); } @mkdir(dirname($dbpath), 0755, true); } if ($readonly && $path != ':memory:' && !file_exists($dbpath)) { throw new Exception('Cannot create SQLite3 registry, registry is read-only'); } static::$databases[$path] = new \SQLite3($dbpath); // ScottMac needs to fix sqlite3 FIXME if (static::$databases[$path]->lastErrorCode()) { $error = static::$databases[$path]->lastErrorMsg(); throw new Exception('Cannot open SQLite3 registry: ' . $error); } $sql = 'SELECT version FROM pearregistryversion'; if (@static::getRegistry($path)->querySingle($sql) == '1.0.0') { return; } if ($readonly) { throw new Exception('Cannot create SQLite3 registry, registry is read-only'); } $a = new Sqlite3\Creator(); try { $a->create(static::$databases[$path]); } catch (\Exception $e) { unset(static::$databases[$path]); $a = get_class($e); throw new $a('Database initialization failed', 0, $e); } }
/** * Returns a list of registries present in the PEAR installation at $path * @param string * @return array */ public static function detectRegistries($path) { if (isset(Main::$options['packagingroot'])) { $path = Main::prepend(Main::$options['packagingroot'], $path); } if (file_exists($path . '/.xmlregistry') || is_dir($path . '/.xmlregistry')) { return array('Xml'); } return array(); }
/** * Returns a list of registries present in the PEAR installation at $path * @param string * @return array */ public static function detectRegistries($path) { if (isset(Main::$options['packagingroot'])) { $path = Main::prepend(Main::$options['packagingroot'], $path); } if (file_exists($path . '/.registry') || is_dir($path . '/.registry')) { return array('Pear1'); } if (basename($path) !== 'php') { $path = $path . DIRECTORY_SEPARATOR . 'php'; } if (file_exists($path . '/.registry') || is_dir($path . '/.registry')) { return array('Pear1'); } return array(); }