8000 [WIP][FileSystem][Enhancement] Fallback to mklink for symlinks/junctions by c33s · Pull Request #18324 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[WIP][FileSystem][Enhancement] Fallback to mklink for symlinks/junctions #18324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
namespace Symfony\Component\Filesystem;

use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Process\Executabl 8000 eFinder;
use Symfony\Component\Process\ProcessBuilder;

/**
* Provides basic utility to manipulate the file system.
Expand Down Expand Up @@ -311,6 +313,13 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false)
}
}


if ($this->existsJunctionExecutable()) {
$this->createWindowsJunction($originDir, $targetDir);
$ok = true;
}


if (!$ok && true !== @symlink($originDir, $targetDir)) {
$report = error_get_last();
if (is_array($report)) {
Expand All @@ -322,6 +331,35 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false)
}
}

protected function existsJunctionExecutable()
{
if ($this->getJunctionExecutable()) {
return true;
}

return false;
}

protected function getJunctionExecutable()
{
$executableFinder = new ExecutableFinder();

return $executableFinder->find('junction');
}

protected function createWindowsJunction($originDir, $targetDir)
{
$junction = $this->getJunctionExecutable();

$processBuilder = new ProcessBuilder();
$process = $processBuilder
->setPrefix($junction)
->setArguments(array($targetDir, $originDir))
->getProcess()
;
$process->run();
}

/**
* Given an existing path, convert it to a path relative to a given starting path.
*
Expand Down
0