Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
[FileSystem] throwing runtimexception when creation of symlink fails …
…due to an error
  • Loading branch information
Erik Trapman committed Jun 14, 2012
commit d0d848f864364049aae7aabef4747ad355e7c005
15 changes: 8 additions & 7 deletions src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function rename($origin, $target)
* @param string $targetDir The symbolic link name
* @param Boolean $copyOnWindows Whether to copy files if on Windows
*
* @throws \RuntimeException When creation of symlink raises an error
* @throws \RuntimeException When creation of symlink raises an error that should not be suppressed
*/
public function symlink($originDir, $targetDir, $copyOnWindows = false)
{
Expand All @@ -171,13 +171,14 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false)
}

if (!$ok) {
try {
symlink($originDir, $targetDir);
} catch (\ErrorException $e) {
if (defined('PHP_WINDOWS_VERSION_MAJOR') && false !== strpos($e->getMessage(), 'error code(1314)')) {
throw new \RuntimeException("Unable to create symlink due to error code 1314: A required privilege is not held by the client. Do you have the required Administrator-rights?");
if (false === @symlink($originDir, $targetDir)) {
$report = error_get_last();
if (is_array($report) && $report['type'] & error_reporting()) {
if (defined('PHP_WINDOWS_VERSION_MAJOR') && false !== strpos($report['message'], 'error code(1314)')) {
throw new \RuntimeException('Unable to create symlink due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?');
}
throw new \RuntimeException(sprintf("%s in %s line %s", $report['message'], $report['file'], $report['line']));
}
throw $e;
}
}
}
Expand Down