当前位置: 首页>>代码示例>>PHP>>正文


PHP phutil_is_windows函数代码示例

本文整理汇总了PHP中phutil_is_windows函数的典型用法代码示例。如果您正苦于以下问题:PHP phutil_is_windows函数的具体用法?PHP phutil_is_windows怎么用?PHP phutil_is_windows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了phutil_is_windows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testMoveReAdd

 function testMoveReAdd()
 {
     if (PHP_OS == 'Linux' && getenv('TRAVIS')) {
         $this->assertSkipped('openvz and inotify unlinks == bad time');
     }
     $dir = new WatchmanDirectoryFixture();
     $root = $dir->getPath();
     mkdir("{$root}/foo");
     $watch = $this->watch($root);
     $this->assertFileListUsingSince($root, 'n:foo', array('foo'), array('foo'));
     $this->watchmanCommand('log', 'debug', 'XXX: touch foo/222');
     touch("{$root}/foo/222");
     $this->assertFileListUsingSince($root, 'n:foo', array('foo', 'foo/222'), array('foo/222'));
     $this->watchmanCommand('log', 'debug', 'XXX: mkdir foo/bar');
     mkdir("{$root}/foo/bar");
     $since = array('foo/bar');
     if (PHP_OS == 'SunOS' || phutil_is_windows()) {
         // This makes me sad, but Solaris reports the parent dir
         // as changed when we mkdir within it
         array_unshift($since, 'foo');
     }
     $this->assertFileListUsingSince($root, 'n:foo', array('foo', 'foo/222', 'foo/bar'), $since);
     $this->watchmanCommand('log', 'debug', 'XXX: rmdir foo/bar');
     rmdir("{$root}/foo/bar");
     $this->watchmanCommand('log', 'debug', 'XXX: unlink foo/222');
     unlink("{$root}/foo/222");
     $this->watchmanCommand('log', 'debug', 'XXX: rmdir foo');
     rmdir("{$root}/foo");
     $this->assertFileListUsingSince($root, 'n:foo', array(), array());
     $this->watchmanCommand('log', 'debug', 'XXX: mkdir foo');
     mkdir("{$root}/foo");
     $this->watchmanCommand('log', 'debug', 'XXX: touch foo/222');
     touch("{$root}/foo/222");
     $this->assertFileListUsingSince($root, 'n:foo', array("foo", "foo/222"), array("foo", "foo/222"));
 }
开发者ID:swn73,项目名称:watchman,代码行数:35,代码来源:movereadd.php

示例2: execute

 /**
  * Execute this command.
  *
  * @return int  Error code returned by the subprocess.
  *
  * @task command
  */
 public function execute()
 {
     $command = $this->command;
     $profiler = PhutilServiceProfiler::getInstance();
     $call_id = $profiler->beginServiceCall(array('type' => 'exec', 'subtype' => 'passthru', 'command' => $command));
     $spec = array(STDIN, STDOUT, STDERR);
     $pipes = array();
     if ($command instanceof PhutilCommandString) {
         $unmasked_command = $command->getUnmaskedString();
     } else {
         $unmasked_command = $command;
     }
     $env = $this->env;
     $cwd = $this->cwd;
     $options = array();
     if (phutil_is_windows()) {
         // Without 'bypass_shell', things like launching vim don't work properly,
         // and we can't execute commands with spaces in them, and all commands
         // invoked from git bash fail horridly, and everything is a mess in
         // general.
         $options['bypass_shell'] = true;
     }
     $trap = new PhutilErrorTrap();
     $proc = @proc_open($unmasked_command, $spec, $pipes, $cwd, $env, $options);
     $errors = $trap->getErrorsAsString();
     $trap->destroy();
     if (!is_resource($proc)) {
         throw new Exception(pht('Failed to passthru %s: %s', 'proc_open()', $errors));
     }
     $err = proc_close($proc);
     $profiler->endServiceCall($call_id, array('err' => $err));
     return $err;
 }
开发者ID:barcelonascience,项目名称:libphutil,代码行数:40,代码来源:PhutilExecPassthru.php

示例3: xhpast_get_binary_path

/**
 * @group xhpast
 */
function xhpast_get_binary_path()
{
    if (phutil_is_windows()) {
        return dirname(__FILE__) . '\\xhpast.exe';
    }
    return dirname(__FILE__) . '/xhpast';
}
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:10,代码来源:xhpast_parse.php

示例4: catCommand

 function catCommand()
 {
     if (!phutil_is_windows()) {
         return array('cat');
     }
     return array(PHP_BINARY, '-d register_argc_argv=1', dirname(__FILE__) . DIRECTORY_SEPARATOR . '_cat.php');
 }
开发者ID:kwlzn,项目名称:watchman,代码行数:7,代码来源:trigger-stdin.php

示例5: getLocalCommitInformation

 public function getLocalCommitInformation()
 {
     if ($this->repositoryHasNoCommits) {
         // Zero commits.
         throw new Exception("You can't get local commit information for a repository with no " . "commits.");
     } else {
         if ($this->relativeCommit == self::GIT_MAGIC_ROOT_COMMIT) {
             // One commit.
             $against = 'HEAD';
         } else {
             // 2..N commits.
             $against = $this->getRelativeCommit() . '..HEAD';
         }
     }
     // NOTE: Windows escaping of "%" symbols apparently is inherently broken;
     // when passed throuhgh escapeshellarg() they are replaced with spaces.
     // TODO: Learn how cmd.exe works and find some clever workaround?
     // NOTE: If we use "%x00", output is truncated in Windows.
     list($info) = $this->execxLocal(phutil_is_windows() ? 'log %s --format=%C --' : 'log %s --format=%s --', $against, '%H%x01%T%x01%P%x01%at%x01%an%x01%s');
     $commits = array();
     $info = trim($info);
     $info = explode("\n", $info);
     foreach ($info as $line) {
         list($commit, $tree, $parents, $time, $author, $title) = explode("", $line, 6);
         $commits[] = array('commit' => $commit, 'tree' => $tree, 'parents' => array_filter(explode(' ', $parents)), 'time' => $time, 'author' => $author, 'summary' => $title);
     }
     return $commits;
 }
开发者ID:nik-kor,项目名称:arcanist,代码行数:28,代码来源:ArcanistGitAPI.php

示例6: phutil_passthru

/**
 * Execute a command which takes over stdin, stdout and stderr, similar to
 * passthru(), but which preserves TTY semantics, escapes arguments, and is
 * traceable.
 *
 * @param  string  sprintf()-style command pattern to execute.
 * @param  ...     Arguments to sprintf pattern.
 * @return int     Return code.
 * @group exec
 */
function phutil_passthru($cmd)
{
    $args = func_get_args();
    $command = call_user_func_array('csprintf', $args);
    $profiler = PhutilServiceProfiler::getInstance();
    $call_id = $profiler->beginServiceCall(array('type' => 'exec', 'subtype' => 'passthru', 'command' => $command));
    $spec = array(STDIN, STDOUT, STDERR);
    $pipes = array();
    if (phutil_is_windows()) {
        // Without 'bypass_shell', things like launching vim don't work properly,
        // and we can't execute commands with spaces in them, and all commands
        // invoked from git bash fail horridly, and everything is a mess in general.
        $options = array('bypass_shell' => true);
        $proc = @proc_open($command, $spec, $pipes, null, null, $options);
    } else {
        $proc = @proc_open($command, $spec, $pipes);
    }
    if ($proc === false) {
        $err = 1;
    } else {
        $err = proc_close($proc);
    }
    $profiler->endServiceCall($call_id, array('err' => $err));
    return $err;
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:35,代码来源:execx.php

示例7: testFields

 function testFields()
 {
     $dir = new WatchmanDirectoryFixture();
     $root = $dir->getPath();
     $watch = $this->watch($root);
     $this->assertFileList($root, array());
     $this->watchmanCommand('log', 'debug', 'XXX: touch a');
     touch("{$root}/a");
     $this->assertFileList($root, array('a'));
     $query = $this->watchmanCommand('query', $root, array('fields' => array('name', 'exists', 'new', 'size', 'mode', 'uid', 'gid', 'mtime', 'mtime_ms', 'mtime_us', 'mtime_ns', 'mtime_f', 'ctime', 'ctime_ms', 'ctime_us', 'ctime_ns', 'ctime_f', 'ino', 'dev', 'nlink', 'oclock', 'cclock'), 'since' => 'n:foo'));
     $this->assertEqual(null, idx($query, 'error'));
     $this->assertEqual(1, count($query['files']));
     $file = $query['files'][0];
     $this->assertEqual('a', $file['name']);
     $this->assertEqual(true, $file['exists']);
     $this->assertEqual(true, $file['new']);
     $stat = stat("{$root}/a");
     $compare_fields = array('size', 'mode', 'uid', 'gid', 'nlink');
     if (!phutil_is_windows()) {
         // These are meaningless in msvcrt, so no sense in comparing them
         $compare_fields[] = 'dev';
         $compare_fields[] = 'ino';
     }
     foreach ($compare_fields as $field) {
         $this->assertEqual($stat[$field], $file[$field], $field);
     }
     $time_fields = array('mtime', 'ctime');
     foreach ($time_fields as $field) {
         $this->assertTimeEqual($stat[$field], $file[$field], $file[$field . '_ms'], $file[$field . '_us'], $file[$field . '_ns'], $file[$field . '_f']);
     }
     $this->assertRegex('/^c:\\d+:\\d+:\\d+:\\d+$/', $file['cclock'], "cclock looks clocky");
     $this->assertRegex('/^c:\\d+:\\d+:\\d+:\\d+$/', $file['oclock'], "oclock looks clocky");
 }
开发者ID:swn73,项目名称:watchman,代码行数:33,代码来源:fields.php

示例8: testPasswords

 public function testPasswords()
 {
     // Normal "%s" doesn't do anything special.
     $command = csprintf('echo %s', 'hunter2trustno1');
     $this->assertTrue(strpos($command, 'hunter2trustno1') !== false);
     // "%P" takes a PhutilOpaqueEnvelope.
     $caught = null;
     try {
         csprintf('echo %P', 'hunter2trustno1');
     } catch (Exception $ex) {
         $caught = $ex;
     }
     $this->assertTrue($caught instanceof Exception);
     // "%P" masks the provided value.
     $command = csprintf('echo %P', new PhutilOpaqueEnvelope('hunter2trustno1'));
     $this->assertFalse(strpos($command, 'hunter2trustno1'));
     // Executing the command works as expected.
     list($out) = execx('%C', $command);
     $this->assertTrue(strpos($out, 'hunter2trustno1') !== false);
     // Escaping should be robust even when used to escape commands which take
     // other commands.
     if (!phutil_is_windows()) {
         list($out) = execx('sh -c %s', csprintf('sh -c %s', csprintf('sh -c %s', csprintf('echo %P', new PhutilOpaqueEnvelope('!@#$%^&*()')))));
         $this->assertTrue(strpos($out, '!@#$%^&*()') !== false);
     }
 }
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:26,代码来源:PhutilcsprintfTestCase.php

示例9: getPath

 /**
  * Returns the path to the XHPAST binary.
  *
  * @return string
  */
 public static function getPath()
 {
     if (phutil_is_windows()) {
         return dirname(__FILE__) . '\\xhpast.exe';
     }
     return dirname(__FILE__) . '/xhpast';
 }
开发者ID:bearinchina,项目名称:libphutil,代码行数:12,代码来源:PhutilXHPASTBinary.php

示例10: testSlash

 function testSlash()
 {
     if (phutil_is_windows()) {
         $this->assertSkipped("N/A for Windows");
     }
     $res = $this->watch('/', false);
     $this->assertEqual('unable to resolve root /: cannot watch "/"', idx($res, 'error'));
 }
开发者ID:xihaxiaozi1,项目名称:watchman,代码行数:8,代码来源:absroot.php

示例11: getParentPath

 /**
  * Return the canonical parent directory for a path. Note, returns "/" when
  * passed "/".
  *
  * @param string Some repository path.
  * @return string That path's canonical parent directory.
  * @task pathutil
  */
 public static function getParentPath($path)
 {
     $path = self::normalizePath($path);
     $path = dirname($path);
     if (phutil_is_windows() && $path == '\\') {
         $path = '/';
     }
     return $path;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:17,代码来源:DiffusionPathIDQuery.php

示例12: raiseWarning

 private function raiseWarning($bin, $message)
 {
     if (phutil_is_windows()) {
         $preamble = pht("The '%s' binary could not be found. Set the webserver's %s " . "environmental variable to include the directory where it resides, or " . "add that directory to '%s' in the Phabricator configuration.", $bin, 'PATH', 'environment.append-paths');
     } else {
         $preamble = pht("The '%s' binary could not be found. Symlink it into '%s', or set the " . "webserver's %s environmental variable to include the directory where " . "it resides, or add that directory to '%s' in the Phabricator " . "configuration.", $bin, 'phabricator/support/bin/', 'PATH', 'environment.append-paths');
     }
     $this->newIssue('bin.' . $bin)->setShortName(pht("'%s' Missing", $bin))->setName(pht("Missing '%s' Binary", $bin))->setSummary(pht("The '%s' binary could not be located or executed.", $bin))->setMessage($preamble . ' ' . $message)->addPhabricatorConfig('environment.append-paths');
 }
开发者ID:denghp,项目名称:phabricator,代码行数:9,代码来源:PhabricatorSetupCheckBinaries.php

示例13: getOptions

 public function getOptions()
 {
     if (phutil_is_windows()) {
         $paths = array();
     } else {
         $paths = array('/bin', '/usr/bin', '/usr/local/bin');
     }
     $path = getenv('PATH');
     return array($this->newOption('phabricator.base-uri', 'string', null)->setLocked(true)->setSummary(pht('URI where Phabricator is installed.'))->setDescription(pht('Set the URI where Phabricator is installed. Setting this ' . 'improves security by preventing cookies from being set on other ' . 'domains, and allows daemons to send emails with links that have ' . 'the correct domain.'))->addExample('http://phabricator.example.com/', pht('Valid Setting')), $this->newOption('phabricator.production-uri', 'string', null)->setSummary(pht('Primary install URI, for multi-environment installs.'))->setDescription(pht('If you have multiple Phabricator environments (like a ' . 'development/staging environment for working on testing ' . 'Phabricator, and a production environment for deploying it), ' . 'set the production environment URI here so that emails and other ' . 'durable URIs will always generate with links pointing at the ' . 'production environment. If unset, defaults to ' . '{{phabricator.base-uri}}. Most installs do not need to set ' . 'this option.'))->addExample('http://phabricator.example.com/', pht('Valid Setting')), $this->newOption('phabricator.allowed-uris', 'list<string>', array())->setLocked(true)->setSummary(pht('Alternative URIs that can access Phabricator.'))->setDescription(pht("These alternative URIs will be able to access 'normal' pages " . "on your Phabricator install. Other features such as OAuth " . "won't work. The major use case for this is moving installs " . "across domains."))->addExample("http://phabricator2.example.com/\n" . "http://phabricator3.example.com/", pht('Valid Setting')), $this->newOption('phabricator.timezone', 'string', null)->setSummary(pht('The timezone Phabricator should use.'))->setDescription(pht("PHP requires that you set a timezone in your php.ini before " . "using date functions, or it will emit a warning. If this isn't " . "possible (for instance, because you are using HPHP) you can set " . "some valid constant for date_default_timezone_set() here and " . "Phabricator will set it on your behalf, silencing the warning."))->addExample('America/New_York', pht('US East (EDT)'))->addExample('America/Chicago', pht('US Central (CDT)'))->addExample('America/Boise', pht('US Mountain (MDT)'))->addExample('America/Los_Angeles', pht('US West (PDT)')), $this->newOption('phabricator.cookie-prefix', 'string', null)->setSummary(pht('Set a string Phabricator should use to prefix ' . 'cookie names'))->setDescription(pht('Cookies set for x.com are also sent for y.x.com. Assuming ' . 'Phabricator instances are running on both domains, this will ' . 'create a collision preventing you from logging in.'))->addExample('dev', pht('Prefix cookie with "dev"')), $this->newOption('phabricator.show-beta-applications', 'bool', false)->setBoolOptions(array(pht('Install Beta Applications'), pht('Uninstall Beta Applications')))->setSummary(pht('Install applications which are still under development.'))->setDescription(pht("Phabricator includes 'Beta' applications which are in an early " . "stage of development. They range from very rough prototypes to " . "relatively complete (but unpolished) applications.\n\n" . "By default, Beta applications are not installed. You can enable " . "this option to install them if you're interested in previewing " . "upcoming features.\n\n" . "After enabling Beta applications, you can selectively uninstall " . "them (like normal applications).")), $this->newOption('phabricator.serious-business', 'bool', false)->setBoolOptions(array(pht('Serious business'), pht('Shenanigans')))->setSummary(pht('Allows you to remove levity and jokes from the UI.'))->setDescription(pht('By default, Phabricator includes some flavor text in the UI, ' . 'like a prompt to "Weigh In" rather than "Add Comment" in ' . 'Maniphest. If you\'d prefer more traditional UI strings like ' . '"Add Comment", you can set this flag to disable most of the ' . 'extra flavor.')), $this->newOption('remarkup.ignored-object-names', 'string', '/^(Q|V)\\d$/')->setSummary(pht('Text values that match this regex and are also object names ' . 'will not be linked.'))->setDescription(pht('By default, Phabricator links object names in Remarkup fields ' . 'to the corresponding object. This regex can be used to modify ' . 'this behavior; object names that match this regex will not be ' . 'linked.')), $this->newOption('environment.append-paths', 'list<string>', $paths)->setSummary(pht('These paths get appended to your \\$PATH envrionment variable.'))->setDescription(pht("Phabricator occasionally shells out to other binaries on the " . "server. An example of this is the `pygmentize` command, used " . "to syntax-highlight code written in languages other than PHP. " . "By default, it is assumed that these binaries are in the \$PATH " . "of the user running Phabricator (normally 'apache', 'httpd', or " . "'nobody'). Here you can add extra directories to the \$PATH " . "environment variable, for when these binaries are in " . "non-standard locations.\n\n" . "Note that you can also put binaries in " . "`phabricator/support/bin/` (for example, by symlinking them).\n\n" . "The current value of PATH after configuration is applied is:\n\n" . "  lang=text\n" . "  %s", $path))->setLocked(true)->addExample('/usr/local/bin', pht('Add One Path'))->addExample("/usr/bin\n/usr/local/bin", pht('Add Multiple Paths')), $this->newOption('config.lock', 'set', array())->setLocked(true)->setDescription(pht('Additional configuration options to lock.')), $this->newOption('config.hide', 'set', array())->setLocked(true)->setDescription(pht('Additional configuration options to hide.')), $this->newOption('config.mask', 'set', array())->setLocked(true)->setDescription(pht('Additional configuration options to mask.')), $this->newOption('config.ignore-issues', 'set', array())->setLocked(true)->setDescription(pht('Setup issues to ignore.')), $this->newOption('phabricator.env', 'string', null)->setLocked(true)->setDescription(pht('Internal.')), $this->newOption('test.value', 'wild', null)->setLocked(true)->setDescription(pht('Unit test value.')), $this->newOption('phabricator.uninstalled-applications', 'set', array())->setLocked(true)->setDescription(pht('Array containing list of Uninstalled applications.')), $this->newOption('phabricator.application-settings', 'wild', array())->setLocked(true)->setDescription(pht('Customized settings for Phabricator applications.')), $this->newOption('welcome.html', 'string', null)->setLocked(true)->setDescription(pht('Custom HTML to show on the main Phabricator dashboard.')), $this->newOption('phabricator.cache-namespace', 'string', null)->setLocked(true)->setDescription(pht('Cache namespace.')), $this->newOption('phabricator.allow-email-users', 'bool', false)->setBoolOptions(array(pht('Allow'), pht('Disallow')))->setDescription(pht('Allow non-members to interact with tasks over email.')));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:10,代码来源:PhabricatorCoreConfigOptions.php

示例14: execPassthru

 public function execPassthru($pattern)
 {
     $args = func_get_args();
     if (phutil_is_windows()) {
         $args[0] = 'hg ' . $args[0];
     } else {
         $args[0] = 'HGPLAIN=1 hg ' . $args[0];
     }
     return call_user_func_array('phutil_passthru', $args);
 }
开发者ID:lewisf,项目名称:arcanist,代码行数:10,代码来源:ArcanistMercurialAPI.php

示例15: testEscapingIsRobust

 public function testEscapingIsRobust()
 {
     if (phutil_is_windows()) {
         $this->assertSkipped(pht("This test doesn't work on Windows."));
     }
     // Escaping should be robust even when used to escape commands which take
     // other commands.
     list($out) = execx('sh -c %s', csprintf('sh -c %s', csprintf('sh -c %s', csprintf('echo %P', new PhutilOpaqueEnvelope('!@#$%^&*()')))));
     $this->assertTrue(strpos($out, '!@#$%^&*()') !== false);
 }
开发者ID:pritambaral,项目名称:libphutil,代码行数:10,代码来源:PhutilCsprintfTestCase.php


注:本文中的phutil_is_windows函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。