本文整理汇总了PHP中Filesystem::resolvePath方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::resolvePath方法的具体用法?PHP Filesystem::resolvePath怎么用?PHP Filesystem::resolvePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filesystem
的用法示例。
在下文中一共展示了Filesystem::resolvePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadOneSkinSpecification
public static function loadOneSkinSpecification($name)
{
// Only allow skins which we know to exist to load. This prevents loading
// skins like "../../secrets/evil/".
$all = self::loadAllSkinSpecifications();
if (empty($all[$name])) {
throw new Exception(pht('Blog skin "%s" is not a valid skin!', $name));
}
$paths = PhabricatorEnv::getEnvConfig('phame.skins');
$base = dirname(phutil_get_library_root('phabricator'));
foreach ($paths as $path) {
$path = Filesystem::resolvePath($path, $base);
$skin_path = $path . DIRECTORY_SEPARATOR . $name;
if (is_dir($skin_path)) {
// Double check that the skin really lives in the skin directory.
if (!Filesystem::isDescendant($skin_path, $path)) {
throw new Exception(pht('Blog skin "%s" is not located in path "%s"!', $name, $path));
}
$spec = self::loadSkinSpecification($skin_path);
if ($spec) {
$spec->setName($name);
return $spec;
}
}
}
return null;
}
示例2: run
public function run()
{
$paths = $this->getPaths();
$affected_tests = array();
foreach ($paths as $path) {
$absolute_path = Filesystem::resolvePath($path);
if (is_dir($absolute_path)) {
$absolute_test_path = Filesystem::resolvePath('tests/' . $path);
if (is_readable($absolute_test_path)) {
$affected_tests[] = $absolute_test_path;
}
}
if (is_readable($absolute_path)) {
$filename = basename($path);
$directory = dirname($path);
// assumes directory layout: tests/<package>/test_<module>.py
$relative_test_path = 'tests/' . $directory . '/test_' . $filename;
$absolute_test_path = Filesystem::resolvePath($relative_test_path);
if (is_readable($absolute_test_path)) {
$affected_tests[] = $absolute_test_path;
}
}
}
return $this->runTests($affected_tests, './');
}
示例3: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$paths = $args->getArg('paths');
if (!$paths) {
$paths = array(getcwd());
}
$targets = array();
foreach ($paths as $path) {
$root = Filesystem::resolvePath($path);
if (!Filesystem::pathExists($root) || !is_dir($root)) {
throw new PhutilArgumentUsageException(pht('Path "%s" does not exist, or is not a directory.', $path));
}
$libraries = id(new FileFinder($path))->withPath('*/__phutil_library_init__.php')->find();
if (!$libraries) {
throw new PhutilArgumentUsageException(pht('Path "%s" contains no libphutil libraries.', $path));
}
foreach ($libraries as $library) {
$targets[] = Filesystem::resolvePath(dirname($library)) . '/';
}
}
$targets = array_unique($targets);
foreach ($targets as $library) {
echo tsprintf("**<bg:blue> %s </bg>** %s\n", pht('EXTRACT'), pht('Extracting "%s"...', Filesystem::readablePath($library)));
$this->extractLibrary($library);
}
return 0;
}
开发者ID:endlessm,项目名称:phabricator,代码行数:28,代码来源:PhabricatorInternationalizationManagementExtractWorkflow.php
示例4: getPathArgumentForLinterFuture
protected function getPathArgumentForLinterFuture($path)
{
$full_path = Filesystem::resolvePath($path);
$ret = array($full_path);
// The |path| we get fed needs to be made relative to the project_root,
// otherwise the |engine| won't recognise it.
$relative_path = Filesystem::readablePath($full_path, $this->getProjectRoot());
$changed = $this->getEngine()->getPathChangedLines($relative_path);
if ($changed !== null) {
// Convert the ordered set of changed lines to a list of ranges.
$changed_lines = array_keys(array_filter($changed));
$ranges = array(array($changed_lines[0], $changed_lines[0]));
foreach (array_slice($changed_lines, 1) as $line) {
$range = last($ranges);
if ($range[1] + 1 === $line) {
++$range[1];
$ranges[last_key($ranges)] = $range;
} else {
$ranges[] = array($line, $line);
}
}
foreach ($ranges as $range) {
$ret[] = sprintf('--lines=%d:%d', $range[0], $range[1]);
}
}
return csprintf('%Ls', $ret);
}
示例5: readBookConfiguration
protected function readBookConfiguration($book_path)
{
if ($book_path === null) {
throw new PhutilArgumentUsageException('Specify a Diviner book configuration file with --book.');
}
$book_data = Filesystem::readFile($book_path);
$book = json_decode($book_data, true);
if (!is_array($book)) {
throw new PhutilArgumentUsageException("Book configuration '{$book_path}' is not in JSON format.");
}
PhutilTypeSpec::checkMap($book, array('name' => 'string', 'title' => 'optional string', 'short' => 'optional string', 'preface' => 'optional string', 'root' => 'optional string', 'uri.source' => 'optional string', 'rules' => 'optional map<regex, string>', 'exclude' => 'optional regex|list<regex>', 'groups' => 'optional map<string, map<string, wild>>'));
// If the book specifies a "root", resolve it; otherwise, use the directory
// the book configuration file lives in.
$full_path = dirname(Filesystem::resolvePath($book_path));
if (empty($book['root'])) {
$book['root'] = '.';
}
$book['root'] = Filesystem::resolvePath($book['root'], $full_path);
if (!preg_match('/^[a-z][a-z-]*\\z/', $book['name'])) {
$name = $book['name'];
throw new PhutilArgumentUsageException("Book configuration '{$book_path}' has name '{$name}', but book names " . "must include only lowercase letters and hyphens.");
}
foreach (idx($book, 'groups', array()) as $group) {
PhutilTypeSpec::checkmap($group, array('name' => 'string', 'include' => 'optional regex|list<regex>'));
}
$this->bookConfigPath = $book_path;
$this->config = $book;
}
示例6: run
public function run()
{
$revisions = $this->getConduit()->callMethodSynchronous('differential.query', array('authors' => array($this->getUserPHID()), 'status' => 'status-open'));
if (!$revisions) {
echo "You have no open Differential revisions.\n";
return 0;
}
$repository_api = $this->getRepositoryAPI();
$info = array();
$status_len = 0;
foreach ($revisions as $key => $revision) {
$revision_path = Filesystem::resolvePath($revision['sourcePath']);
$current_path = Filesystem::resolvePath($repository_api->getPath());
if ($revision_path == $current_path) {
$info[$key]['here'] = 1;
} else {
$info[$key]['here'] = 0;
}
$info[$key]['sort'] = sprintf('%d%04d%08d', $info[$key]['here'], $revision['status'], $revision['id']);
$info[$key]['statusColorized'] = BranchInfo::renderColorizedRevisionStatus($revision['statusName']);
$status_len = max($status_len, strlen($info[$key]['statusColorized']));
}
$info = isort($info, 'sort');
foreach ($info as $key => $spec) {
$revision = $revisions[$key];
printf("%s %-" . ($status_len + 4) . "s D%d: %s\n", $spec['here'] ? phutil_console_format('**%s**', '*') : ' ', $spec['statusColorized'], $revision['id'], $revision['title']);
}
return 0;
}
示例7: run
public function run()
{
if ($this->getRunAllTests()) {
$root = $this->getWorkingCopy()->getProjectRoot();
$all_tests = glob(Filesystem::resolvePath("{$root}/tests/**/test_*.py"));
return $this->runTests($all_tests, $root);
}
$paths = $this->getPaths();
$affected_tests = array();
foreach ($paths as $path) {
$absolute_path = Filesystem::resolvePath($path);
if (is_dir($absolute_path)) {
$absolute_test_path = Filesystem::resolvePath('tests/' . $path);
if (is_readable($absolute_test_path)) {
$affected_tests[] = $absolute_test_path;
}
}
if (is_readable($absolute_path)) {
$filename = basename($path);
$directory = dirname($path);
// assumes directory layout: tests/<package>/test_<module>.py
$relative_test_path = 'tests/' . $directory . '/test_' . $filename;
$absolute_test_path = Filesystem::resolvePath($relative_test_path);
if (is_readable($absolute_test_path)) {
$affected_tests[] = $absolute_test_path;
}
}
}
return $this->runTests($affected_tests, './');
}
示例8: run
public function run()
{
static $color_map = array('Closed' => 'cyan', 'Needs Review' => 'magenta', 'Needs Revision' => 'red', 'Changes Planned' => 'red', 'Accepted' => 'green', 'No Revision' => 'blue', 'Abandoned' => 'default');
$revisions = $this->getConduit()->callMethodSynchronous('differential.query', array('authors' => array($this->getUserPHID()), 'status' => 'status-open'));
if (!$revisions) {
echo pht('You have no open Differential revisions.') . "\n";
return 0;
}
$repository_api = $this->getRepositoryAPI();
$info = array();
foreach ($revisions as $key => $revision) {
$revision_path = Filesystem::resolvePath($revision['sourcePath']);
$current_path = Filesystem::resolvePath($repository_api->getPath());
if ($revision_path == $current_path) {
$info[$key]['exists'] = 1;
} else {
$info[$key]['exists'] = 0;
}
$info[$key]['sort'] = sprintf('%d%04d%08d', $info[$key]['exists'], $revision['status'], $revision['id']);
$info[$key]['statusName'] = $revision['statusName'];
$info[$key]['color'] = idx($color_map, $revision['statusName'], 'default');
}
$table = id(new PhutilConsoleTable())->setShowHeader(false)->addColumn('exists', array('title' => ''))->addColumn('status', array('title' => pht('Status')))->addColumn('title', array('title' => pht('Title')));
$info = isort($info, 'sort');
foreach ($info as $key => $spec) {
$revision = $revisions[$key];
$table->addRow(array('exists' => $spec['exists'] ? phutil_console_format('**%s**', '*') : '', 'status' => phutil_console_format("<fg:{$spec['color']}>%s</fg>", $spec['statusName']), 'title' => phutil_console_format('**D%d:** %s', $revision['id'], $revision['title'])));
}
$table->draw();
return 0;
}
示例9: run
public function run()
{
$argv = $this->getArgument('argv');
if (count($argv) > 1) {
throw new ArcanistUsageException("Provide only one path to 'arc liberate'. The path should be a " . "directory where you want to create or update a libphutil library.");
} else {
if (count($argv) == 0) {
$path = getcwd();
} else {
$path = reset($argv);
}
}
$is_remap = $this->getArgument('remap');
$is_verify = $this->getArgument('verify');
$path = Filesystem::resolvePath($path);
if (Filesystem::pathExists($path) && is_dir($path)) {
$init = id(new FileFinder($path))->withPath('*/__phutil_library_init__.php')->find();
} else {
$init = null;
}
if ($init) {
if (count($init) > 1) {
throw new ArcanistUsageException("Specified directory contains more than one libphutil library. Use " . "a more specific path.");
}
$path = Filesystem::resolvePath(dirname(reset($init)), $path);
} else {
$found = false;
foreach (Filesystem::walkToRoot($path) as $dir) {
if (Filesystem::pathExists($dir . '/__phutil_library_init__.php')) {
$path = $dir;
$found = true;
break;
}
}
if (!$found) {
echo "No library currently exists at that path...\n";
$this->liberateCreateDirectory($path);
$this->liberateCreateLibrary($path);
return;
}
}
$version = $this->getLibraryFormatVersion($path);
switch ($version) {
case 1:
if ($this->getArgument('upgrade')) {
return $this->upgradeLibrary($path);
}
throw new ArcanistUsageException("This library is using libphutil v1, which is no longer supported. " . "Run 'arc liberate --upgrade' to upgrade to v2.");
case 2:
if ($this->getArgument('upgrade')) {
throw new ArcanistUsageException("Can't upgrade a v2 library!");
}
return $this->liberateVersion2($path);
default:
throw new ArcanistUsageException("Unknown library version '{$version}'!");
}
}
示例10: saveToArchive
public function saveToArchive($path)
{
$tmp = new TempFile();
execx('tar -C %s -czvvf %s .', $this->getPath(), $tmp);
$ok = rename($tmp, Filesystem::resolvePath($path));
if (!$ok) {
throw new FilesystemException($path, 'Failed to overwrite file.');
}
return $this;
}
示例11: loadDictionary
public function loadDictionary($path)
{
$root = $this->getProjectRoot();
$path = Filesystem::resolvePath($path, $root);
$dict = phutil_json_decode(Filesystem::readFile($path));
PhutilTypeSpec::checkMap($dict, array('rules' => 'map<string, map<string, string>>'));
$rules = $dict['rules'];
$this->dictionaries[] = $path;
$this->exactWordRules = array_merge($this->exactWordRules, idx($rules, 'exact', array()));
$this->partialWordRules = array_merge($this->partialWordRules, idx($rules, 'partial', array()));
}
示例12: xhpast_get_build_instructions
/**
* @group xhpast
*/
function xhpast_get_build_instructions()
{
$root = phutil_get_library_root('phutil');
$make = $root . '/../scripts/build_xhpast.sh';
$make = Filesystem::resolvePath($make);
return <<<EOHELP
Your version of 'xhpast' is unbuilt or out of date. Run this script to build it:
\$ {$make}
EOHELP;
}
示例13: newForPath
/**
* Create a new lock on a lockfile. The file need not exist yet.
*
* @param string The lockfile to use.
* @return PhutilFileLock New lock object.
*
* @task construct
*/
public static function newForPath($lockfile)
{
$lockfile = Filesystem::resolvePath($lockfile);
$name = 'file:' . $lockfile;
$lock = self::getLock($name);
if (!$lock) {
$lock = new PhutilFileLock($name);
$lock->lockfile = $lockfile;
self::registerLock($lock);
}
return $lock;
}
示例14: phutil_get_library_name_for_root
function phutil_get_library_name_for_root($path)
{
$path = rtrim(Filesystem::resolvePath($path), '/');
$bootloader = PhutilBootloader::getInstance();
$libraries = $bootloader->getAllLibraries();
foreach ($libraries as $library) {
$root = $bootloader->getLibraryRoot($library);
if (rtrim(Filesystem::resolvePath($root), '/') == $path) {
return $library;
}
}
return null;
}
示例15: run
public function run()
{
$this->projectRoot = $this->getWorkingCopy()->getProjectRoot();
$this->affectedTests = array();
foreach ($this->getPaths() as $path) {
$path = Filesystem::resolvePath($path);
// TODO: add support for directories
// Users can call phpunit on the directory themselves
if (is_dir($path)) {
continue;
}
// Not sure if it would make sense to go further if
// it is not a .php file
if (substr($path, -4) != '.php') {
continue;
}
if (substr($path, -8) == 'Test.php') {
// Looks like a valid test file name.
$this->affectedTests[$path] = $path;
continue;
}
if ($test = $this->findTestFile($path)) {
$this->affectedTests[$path] = $test;
}
}
if (empty($this->affectedTests)) {
throw new ArcanistNoEffectException('No tests to run.');
}
$this->prepareConfigFile();
$futures = array();
$tmpfiles = array();
foreach ($this->affectedTests as $class_path => $test_path) {
$json_tmp = new TempFile();
$clover_tmp = null;
$clover = null;
if ($this->getEnableCoverage() !== false) {
$clover_tmp = new TempFile();
$clover = csprintf('--coverage-clover %s', $clover_tmp);
}
$config = $this->configFile ? csprintf('-c %s', $this->configFile) : null;
$futures[$test_path] = new ExecFuture('phpunit %C --log-json %s %C %s', $config, $json_tmp, $clover, $test_path);
$tmpfiles[$test_path] = array('json' => $json_tmp, 'clover' => $clover_tmp);
}
$results = array();
foreach (Futures($futures)->limit(4) as $test => $future) {
list($err, $stdout, $stderr) = $future->resolve();
$results[] = $this->parseTestResults($test_path, $tmpfiles[$test]['json'], $tmpfiles[$test]['clover']);
}
return array_mergev($results);
}