Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit88f47ff

Browse files
committed
handle paths on different drives
1 parent08ded7f commit88f47ff

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

‎src/Symfony/Component/Filesystem/Filesystem.php‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -456,15 +456,18 @@ public function makePathRelative($endPath, $startPath)
456456
}
457457

458458
$stripDriveLetter =function ($path) {
459-
if (\strlen($path) >2 &&':' ===$path[1] &&'/' ===$path[2] &&ctype_alpha($path[0])) {
460-
returnsubstr($path,2);
461-
}
462-
463-
return$path;
459+
return (\strlen($path) >2 &&':' ===$path[1] &&'/' ===$path[2] &&ctype_alpha($path[0]))
460+
? [substr($path,2),$path[0]]
461+
: [$path,null];
464462
};
465463

466-
$endPath =$stripDriveLetter($endPath);
467-
$startPath =$stripDriveLetter($startPath);
464+
list($endPath,$endDriveLetter) =$stripDriveLetter($endPath);
465+
list($startPath,$startDriveLetter) =$stripDriveLetter($startPath);
466+
467+
if ($endDriveLetter &&$startDriveLetter &&$endDriveLetter <>$startDriveLetter) {
468+
// Different drives
469+
return$endDriveLetter.':'.$endPath;
470+
}
468471

469472
// Split the paths into arrays
470473
$startPathArr =explode('/',trim($startPath,'/'));

‎src/Symfony/Component/Filesystem/Tests/FilesystemTest.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,7 @@ public function providePathsForMakePathRelative()
11151115
['C:/aa/bb/../../cc','C:/aa/../dd/..','cc/'],
11161116
['C:/../aa/bb/cc','C:/aa/dd/..','bb/cc/'],
11171117
['C:/../../aa/../bb/cc','C:/aa/dd/..','../bb/cc/'],
1118+
['D:/aa/bb','C:/aa','D:/aa/bb'],
11181119
];
11191120

11201121
if ('\\' === \DIRECTORY_SEPARATOR) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp