private function createConfig($root, $pearConfDir)
{
$old = error_reporting(0);
$windows = $this->isWindows();
$ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
$root = preg_replace(array('!\\\\+!', '!/+!', "!{$ds2}+!"), array('/', '/', '/'), $root);
if ($root[0] != '/') {
if ($windows) {
throw new Exception('Root directory must be an absolute path beginning ' . 'with "/", was: "' . $root . '"');
}
if (!preg_match('/^[A-Za-z]:/', $root)) {
throw new Exception('Root directory must be an absolute path beginning ' . 'with "\\" or "C:\\", was: "' . $root . '"');
}
}
if ($windows) {
$root = str_replace('/', '\\', $root);
}
if (!file_exists($pearConfDir) && !@touch($pearConfDir)) {
throw new Exception('Could not create "' . $pearConfDir . '"');
}
$config = new PEAR_Config($pearConfDir, '#no#system#config#', false, false);
if ($root[strlen($root) - 1] == '/') {
$root = substr($root, 0, strlen($root) - 1);
}
$config->noRegistry();
$config->set('php_dir', $windows ? "{$root}" : "{$root}", 'user');
$config->set('data_dir', $windows ? "{$root}\\pear\\data" : "{$root}/data");
$config->set('www_dir', $windows ? "{$root}\\pear\\www" : "{$root}/pear/www");
$config->set('cfg_dir', $windows ? "{$root}\\pear\\cfg" : "{$root}/pear/cfg");
$config->set('ext_dir', $windows ? "{$root}\\pear\\ext" : "{$root}/pear/ext");
$config->set('doc_dir', $windows ? "{$root}\\pear\\docs" : "{$root}/pear/docs");
$config->set('test_dir', $windows ? "{$root}\\pear\\tests" : "{$root}/pear/tests");
$config->set('cache_dir', $windows ? "{$root}\\pear\\cache" : "{$root}/pear/cache");
$config->set('download_dir', $windows ? "{$root}\\pear\\download" : "{$root}/pear/download");
$config->set('temp_dir', $windows ? "{$root}\\pear\\temp" : "{$root}/pear/temp");
$config->set('bin_dir', $windows ? "{$root}\\" : "{$root}/");
$config->writeConfigFile();
error_reporting($old);
return $config;
}