Skip to content

Commit 2e9e83e

Browse files
bug symfony#17615 Ensure backend slashes for symlinks on Windows systems (cpsitgmbh)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes symfony#17615). Discussion ---------- Ensure backend slashes for symlinks on Windows systems Resolves: symfony#17614 Commits ------- d897956 Ensure backend slashes for symlinks on Windows systems
2 parents 36cb46a + d897956 commit 2e9e83e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,15 @@ private function isReadable($filename)
301301
*/
302302
public function symlink($originDir, $targetDir, $copyOnWindows = false)
303303
{
304-
if ($copyOnWindows && !function_exists('symlink')) {
305-
$this->mirror($originDir, $targetDir);
304+
if ('\\' === DIRECTORY_SEPARATOR) {
305+
$originDir = strtr($originDir, '/', '\\');
306+
$targetDir = strtr($targetDir, '/', '\\');
307+
308+
if ($copyOnWindows) {
309+
$this->mirror($originDir, $targetDir);
306310

307-
return;
311+
return;
312+
}
308313
}
309314

310315
$this->mkdir(dirname($targetDir));

0 commit comments

Comments
 (0)