Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Filesystem.php

function Filesystem::junction

Creates an NTFS junction.

Return value

void

File

vendor/composer/composer/src/Composer/Util/Filesystem.php, line 828

Class

Filesystem
@author Jordi Boggiano <j.boggiano@seld.be> @author Johannes M. Schmitt <schmittjoh@gmail.com>

Namespace

Composer\Util

Code

public function junction(string $target, string $junction) {
    if (!Platform::isWindows()) {
        throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
    }
    if (!is_dir($target)) {
        throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target);
    }
    // Removing any previously junction to ensure clean execution.
    if (!is_dir($junction) || $this->isJunction($junction)) {
        @rmdir($junction);
    }
    $cmd = [
        'mklink',
        '/J',
        str_replace('/', DIRECTORY_SEPARATOR, $junction),
        Platform::realpath($target),
    ];
    if ($this->getProcess()
        ->execute($cmd, $output) !== 0) {
        throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target);
    }
    clearstatcache(true, $junction);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal