mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-01-06 04:41:00 +01:00
[Wilds] Implement a Filesystem::concatenatePaths(...) method
Summary: Ref T13098. This is mostly for getting sensible results under Windows, hopefully instead of weird mixed paths with both `/` and `\`, at least in more cases. You can pass in several components like `array('/path/to/something/', '/thing.c')` and they'll be concatenated with exactly one correct separator. Test Plan: Used this in the new `WorkingCopy` stuff, which doesn't run yet. 💁 Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13098 Differential Revision: https://secure.phabricator.com/D19691
This commit is contained in:
parent
c05bbd7be6
commit
11599cedb6
1 changed files with 12 additions and 0 deletions
|
@ -1047,6 +1047,18 @@ final class Filesystem extends Phobject {
|
|||
return ($u == $v);
|
||||
}
|
||||
|
||||
public static function concatenatePaths(array $components) {
|
||||
$components = implode($components, DIRECTORY_SEPARATOR);
|
||||
|
||||
// Replace any extra sequences of directory separators with a single
|
||||
// separator, so we don't end up with "path//to///thing.c".
|
||||
$components = preg_replace(
|
||||
'('.preg_quote(DIRECTORY_SEPARATOR).'{2,})',
|
||||
DIRECTORY_SEPARATOR);
|
||||
|
||||
return $components;
|
||||
}
|
||||
|
||||
|
||||
/* -( Assert )------------------------------------------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue