本文整理汇总了PHP中OS_Guess::matchSignature方法的典型用法代码示例。如果您正苦于以下问题:PHP OS_Guess::matchSignature方法的具体用法?PHP OS_Guess::matchSignature怎么用?PHP OS_Guess::matchSignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OS_Guess
的用法示例。
在下文中一共展示了OS_Guess::matchSignature方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: substr
/**
* @param string filename
* @param array attributes from <file> tag in package.xml
* @param string path to install the file in
* @param array options from command-line
* @access private
*/
function _installFile($file, $atts, $tmp_path, $options)
{
// {{{ return if this file is meant for another platform
static $os;
if (!isset($this->_registry)) {
$this->_registry =& $this->config->getRegistry();
}
if (isset($atts['platform'])) {
if (empty($os)) {
$os = new OS_Guess();
}
if (strlen($atts['platform']) && $atts['platform'][0] == '!') {
$negate = true;
$platform = substr($atts['platform'], 1);
} else {
$negate = false;
$platform = $atts['platform'];
}
if ((bool) $os->matchSignature($platform) === $negate) {
$this->log(3, "skipped {$file} (meant for {$atts['platform']}, we are " . $os->getSignature() . ")");
return PEAR_INSTALLER_SKIPPED;
}
}
// }}}
$channel = $this->pkginfo->getChannel();
// {{{ assemble the destination paths
switch ($atts['role']) {
case 'doc':
case 'data':
case 'test':
$dest_dir = $this->config->get($atts['role'] . '_dir', null, $channel) . DIRECTORY_SEPARATOR . $this->pkginfo->getPackage();
unset($atts['baseinstalldir']);
break;
case 'ext':
case 'php':
$dest_dir = $this->config->get($atts['role'] . '_dir', null, $channel);
break;
case 'script':
$dest_dir = $this->config->get('bin_dir', null, $channel);
break;
case 'src':
case 'extsrc':
$this->source_files++;
return;
default:
return $this->raiseError("Invalid role `{$atts['role']}' for file {$file}");
}
$save_destdir = $dest_dir;
if (!empty($atts['baseinstalldir'])) {
$dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
}
if (dirname($file) != '.' && empty($atts['install-as'])) {
$dest_dir .= DIRECTORY_SEPARATOR . dirname($file);
}
if (empty($atts['install-as'])) {
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);
} else {
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as'];
}
$orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file;
// Clean up the DIRECTORY_SEPARATOR mess
$ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
list($dest_file, $orig_file) = preg_replace(array('!\\\\+!', '!/!', "!{$ds2}+!"), array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), array($dest_file, $orig_file));
$final_dest_file = $installed_as = $dest_file;
if (isset($this->_options['packagingroot'])) {
$installedas_dest_dir = dirname($final_dest_file);
$installedas_dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
$final_dest_file = $this->_prependPath($final_dest_file, $this->_options['packagingroot']);
} else {
$installedas_dest_dir = dirname($final_dest_file);
$installedas_dest_file = $installedas_dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
}
$dest_dir = dirname($final_dest_file);
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
// }}}
if (empty($this->_options['register-only']) && !@is_dir($dest_dir)) {
if (!$this->mkDirHier($dest_dir)) {
return $this->raiseError("failed to mkdir {$dest_dir}", PEAR_INSTALLER_FAILED);
}
$this->log(3, "+ mkdir {$dest_dir}");
}
// pretty much nothing happens if we are only registering the install
if (empty($this->_options['register-only'])) {
if (empty($atts['replacements'])) {
if (!file_exists($orig_file)) {
return $this->raiseError("file {$orig_file} does not exist", PEAR_INSTALLER_FAILED);
}
if (!@copy($orig_file, $dest_file)) {
return $this->raiseError("failed to write {$dest_file}", PEAR_INSTALLER_FAILED);
}
$this->log(3, "+ cp {$orig_file} {$dest_file}");
if (isset($atts['md5sum'])) {
$md5sum = md5_file($dest_file);
//.........这里部分代码省略.........
示例2: matchSignature
/**
* This makes unit-testing a heck of a lot easier
*/
function matchSignature($pattern)
{
return $this->_os->matchSignature($pattern);
}
示例3: checkOS
/**
* Operating system dependencies check method
*
* @param string $os Name of the operating system
*
* @return mixed bool false if no error or the error string
*/
function checkOS(&$errmsg, $os)
{
// XXX Fixme: Implement a more flexible way, like
// comma separated values or something similar to PEAR_OS
static $myos;
if (empty($myos)) {
$myos = new OS_Guess();
}
// only 'has' relation is currently supported
if ($myos->matchSignature($os)) {
return false;
}
$errmsg = "'{$os}' operating system not supported";
return PEAR_DEPENDENCY_CONFLICT;
}
示例4: switch
function _installFile($file, $atts, $tmp_path)
{
static $os;
if (isset($atts['platform'])) {
if (empty($os)) {
include_once "OS/Guess.php";
$os = new OS_Guess();
}
// return if this file is meant for another platform
if (!$os->matchSignature($atts['platform'])) {
$this->log(3, "skipped {$file} (meant for {$atts['platform']}, we are " . $os->getSignature() . ")");
return PEAR_INSTALLER_SKIPPED;
}
}
switch ($atts['role']) {
case 'doc':
case 'data':
case 'test':
$dest_dir = $this->config->get($atts['role'] . '_dir') . DIRECTORY_SEPARATOR . $this->pkginfo['package'];
unset($atts['baseinstalldir']);
break;
case 'ext':
case 'php':
$dest_dir = $this->config->get($atts['role'] . '_dir');
break;
case 'script':
$dest_dir = $this->config->get('bin_dir');
break;
case 'src':
case 'extsrc':
$this->source_files++;
return;
default:
return $this->raiseError("Invalid role `{$atts['role']}' for file {$file}");
}
if (!empty($atts['baseinstalldir'])) {
$dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
}
if (dirname($file) != '.' && empty($atts['install-as'])) {
$dest_dir .= DIRECTORY_SEPARATOR . dirname($file);
}
if (empty($atts['install-as'])) {
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);
} else {
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as'];
}
$orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file;
// Clean up the DIRECTORY_SEPARATOR mess
$ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
list($dest_file, $orig_file) = preg_replace(array('!\\\\+!', '!/!', "!{$ds2}+!"), DIRECTORY_SEPARATOR, array($dest_file, $orig_file));
$installed_as = $dest_file;
$final_dest_file = $this->_prependPath($dest_file, $this->installroot);
$dest_dir = dirname($final_dest_file);
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
if (!@is_dir($dest_dir)) {
if (!$this->mkDirHier($dest_dir)) {
return $this->raiseError("failed to mkdir {$dest_dir}", PEAR_INSTALLER_FAILED);
}
$this->log(3, "+ mkdir {$dest_dir}");
}
if (empty($atts['replacements'])) {
if (!@copy($orig_file, $dest_file)) {
return $this->raiseError("failed to write {$dest_file}", PEAR_INSTALLER_FAILED);
}
$this->log(3, "+ cp {$orig_file} {$dest_file}");
if (isset($atts['md5sum'])) {
$md5sum = md5_file($dest_file);
}
} else {
$fp = fopen($orig_file, "r");
$contents = fread($fp, filesize($orig_file));
fclose($fp);
if (isset($atts['md5sum'])) {
$md5sum = md5($contents);
}
$subst_from = $subst_to = array();
foreach ($atts['replacements'] as $a) {
$to = '';
if ($a['type'] == 'php-const') {
if (preg_match('/^[a-z0-9_]+$/i', $a['to'])) {
eval("\$to = {$a['to']};");
} else {
$this->log(0, "invalid php-const replacement: {$a['to']}");
continue;
}
} elseif ($a['type'] == 'pear-config') {
$to = $this->config->get($a['to']);
} elseif ($a['type'] == 'package-info') {
$to = $this->pkginfo[$a['to']];
}
if ($to) {
$subst_from[] = $a['from'];
$subst_to[] = $to;
}
}
$this->log(3, "doing " . sizeof($subst_from) . " substitution(s) for {$final_dest_file}");
if (sizeof($subst_from)) {
$contents = str_replace($subst_from, $subst_to, $contents);
}
$wp = @fopen($dest_file, "w");
//.........这里部分代码省略.........