A helper method to quickly emit the directory structure from
either a single file or an array of files to a single output
directory.

@param       $from
@param       $to
@param array $collectorData
@return PathManager
493939
public static function copy($from, $to, $collectorData = [])
    {
        $manager = app(get_called_class());

        if (!is_array($from)) {
            $from = array($from);
        }

        // Iterate over the $collectorData and add any data to the
        // $manager that might be required.
        foreach ($collectorData as $key => $value) {
            // A value of NULL will indicate that the given key should
            // be added to the collector's paths.
            if ($value == null) {
                $manager->addPathToCollector($key);
            } else {
                $manager->addRawToCollector($key, $value);
            }
        }

        $manager->addPaths($from);
        $manager->emitStructure($to);

        return $manager;
    }
1151555
public function moveTrack(int $from, int $to): PlaylistInterface
    {
        $data = $this->soap("AVTransport", "ReorderTracksInSavedQueue", [
            "UpdateID"              =>  $this->getUpdateID(),
            "TrackList"             =>  (string) $from,
            "NewPositionList"       =>  (string) $to,
        ]);
        $this->updateId = $data["NewUpdateID"];

        return $this;
    }
1150240
public function replace($from, $to)
    {
        $values = $this->_replace($from, $to);
        return new Collection($values);
    }
814095
public function copy($from, $to, array $config = [])
    {
        [$fsFrom, $from] = $this->getFilesystemAndPath($from);
        $buffer = $fsFrom->readStream($from);

        if ($buffer === false) {
            return false;
        }

        [$fsTo, $to] = $this->getFilesystemAndPath($to);
        $result = $fsTo->writeStream($to, $buffer, $config);

        if (\is_resource($buffer)) {
            \fclose($buffer);
        }

        return $result;
    }
282801
private function getReplacementString($from, $to)
    {
        if (is_array($from) && is_array($to)) {
            if (count($from) == count($to)) {
                $sedStrings = [];
                $fromSize = count($from);
                for ($i = 0; $i < $fromSize; $i++) {
                    $sedStrings[] = $this->getReplacementCommand($from[$i], $to[$i]);
                }
                return implode(';', $sedStrings);
            } else {
                throw new InvalidArgumentException("Number of items in 'fromText' (" . count($from) . ") is different to 'toText' (" . count($to) . ")");
            }
        } elseif (is_array($from) || is_array($to)) {
            throw new InvalidArgumentException("Only one of fromText or toText is an array, both should be arrays or string");
        } else {
            return $this->getReplacementCommand($from, $to);
        }
    }
131120
public function move(string $from, string $to, array $config = []): bool
    {
        list($prefixFrom, $pathFrom) = $this->getPrefixAndPath($from);
        list($prefixTo, $pathTo) = $this->getPrefixAndPath($to);

        if ($prefixFrom === $prefixTo) {
            $fs = $this->getFileSystem($prefixFrom);
            $renamed = $fs->rename($pathFrom, $pathTo);

            unset($prefixFrom, $pathFrom, $prefixTo);

            if ($renamed && isset($config['visibility'])) {
                return $fs->setVisibility($pathTo, $config['visibility']);
            }

            unset($fs, $pathTo);

            return $renamed;
        }

        if ($this->copy($from, $to, $config)) {
            return $this->delete($from);
        }

        return false;
    }
1369809
protected function moveBetweenFilesystems($fileID, Filesystem $from, Filesystem $to)
    {
        foreach ($this->findVariants($fileID, $from) as $nextID) {
            // Copy via stream
            $stream = $from->readStream($nextID);
            $to->putStream($nextID, $stream);
            if (is_resource($stream)) {
                fclose($stream);
            }
            $from->delete($nextID);
        }

        // Truncate empty dirs
        $this->truncateDirectory(dirname($fileID), $from);
    }
271726
public function fromArray(array $fromArray): DirectoryItem
    {
        $typeExists = array_key_exists('type', $fromArray);
        $dirExists = array_key_exists('dir', $fromArray);

        if ($typeExists === false && $dirExists === true && is_bool($fromArray['dir'])) {
            $fromArray['type'] = $fromArray['dir'] === true ? self::TYPE_DIR : self::TYPE_FILE;
        }

        /**
         * @var self $dirItem
         */
        $dirItem = parent::fromArray($fromArray);

        return $dirItem;
    }
780934
public static function createFrom(self $from, $to = null)
    {
        $request = $to ?: new static;

        $files = $from->files->all();

        $files = is_array($files) ? array_filter($files) : $files;

        $request->initialize(
            $from->query->all(),
            $from->request->all(),
            $from->attributes->all(),
            $from->cookies->all(),
            $files,
            $from->server->all(),
            $from->getContent()
        );

        $request->headers->replace($from->headers->all());

        $request->setJson($from->json());

        if ($session = $from->getSession()) {
            $request->setLaravelSession($session);
        }

        $request->setUserResolver($from->getUserResolver());

        $request->setRouteResolver($from->getRouteResolver());

        return $request;
    }
605997
public function copyFolder( $from, $to )
	{
		$this->connection->checkConnection();
		$this->createFolder( $to );
		$reader	= new Net_FTP_Reader( $this->connection );
		$list	= $reader->getList( $from, TRUE );
		foreach( $list as $entry )
		{
			if( $entry['isdir'] )
				$this->createFolder( $to."/".$entry['name'] );
			else
				$this->copyFile( $from."/".$entry['name'], $to."/".$entry['name'] );
		}
		return TRUE;
	}
771486
protected function fromTo($command, $from, $destination)
    {
        $folder = dirname($destination);
        if (!$this->fileExists($folder)) {
            $this->createFolder($folder);
        }

        return $this->modulable->run(sprintf('%s %s %s', $command, $from, $destination));
    }
532358
public function rename($from, $to) {
    if (!CloudStorageTools::parseFilename($from, $from_bucket, $from_object) ||
        !isset($from_object)) {
      trigger_error(sprintf("Invalid Google Cloud Storage path: %s", $from),
                    E_USER_ERROR);
      return false;
    }
    if (!CloudStorageTools::parseFilename($to, $to_bucket, $to_object) ||
        !isset($to_object)) {
      trigger_error(sprintf("Invalid Google Cloud Storage path: %s", $to),
                    E_USER_ERROR);
      return false;
    }

    // If the file being renamed is an uploaded file being moved to an allowed
    // include bucket trigger a warning.
    $allowed_buckets = $this->getAllowedBuckets();
    foreach ($_FILES as $file) {
      if ($file['tmp_name'] == $from) {
        foreach ($allowed_buckets as $allowed_bucket) {
          // 5th character indicates start of bucket since it ignores 'gs://'.
          if (strpos($to, $allowed_bucket) === 5) {
            trigger_error(sprintf('Moving uploaded file (%s) to an allowed ' .
                                  'include bucket (%s) which may be ' .
                                  'vulnerable to local file inclusion (LFI).',
                                  $from, $allowed_bucket),
                          E_USER_WARNING);
            break 2;
          }
        }
      }
    }

    $client = new CloudStorageRenameClient($from_bucket,
                                           $from_object,
                                           $to_bucket,
                                           $to_object,
                                           $this->context);
    return $client->rename();
  }
995640
public static function createWithoutTransition(Path $path, int $from, int $to): Path
    {
        $fromPlaces = $path->getPlacesAt($from);
        $toPlaces = $path->getPlacesAt($to);
        if (count($fromPlaces) > 1 && count($toPlaces) > 1 && 1 === count(array_diff($fromPlaces, $toPlaces)) &&
            1 === count(array_diff($toPlaces, $fromPlaces))) {
            $path = static::create($path, $from, $to, [], [], []);

            $find = array_values(array_diff($toPlaces, $fromPlaces))[0];
            $replace = array_values(array_diff($fromPlaces, $toPlaces))[0];
            for ($i = $to; $i < $path->countPlaces(); ++$i) {
                $places = $path->getPlacesAt($i);
                $key = array_search($find, $places);
                $newPlaces = array_replace($places, [$key => $replace]);
                $path->setPlacesAt($i, $newPlaces);
            }

            return $path;
        } else {
            throw new Exception('Can not create new path without transition');
        }
    }
765174
public static function getTravelPath($from, $to)
    {
        $from = explode(DS, $from);
        $to = explode(DS, $to);

        $relPath = $to;

        foreach ($from as $depth => $dir) {
            // find first non-matching dir
            if ($dir === $to[$depth]) {
                // ignore this directory
                array_shift($relPath);
            } else {
                // get number of remaining dirs to $from
                $remaining = count($from) - ($depth - 1);
                if ($remaining > 1) {
                    // add traversals up to first matching dir
                    $padLength = (count($relPath) + $remaining - 1) * -1;
                    $relPath = array_pad($relPath, $padLength, '..');
                    break;
                } else {
                    $relPath[0] = './'.$relPath[0];
                }
            }
        }

        return implode('/', $relPath);
    }
19163
public function move($to)
	{
		$dest   = $to . '/' . $this->getDisplayName() . '.' . $this->getExtension();
		$return = $this->hasAdapterOrFail()->adapter->rename($this->getPath(), $dest);

		// Update the internal path
		if ($return)
		{
			$this->path = $dest;
		}

		return $return;
	}
1281101
public function getDecompressCommand(LocalFileNodeInterface $from, LocalFileNodeInterface $to)
    {
        return sprintf("gunzip -c %s > %s", escapeshellarg($from->getPath()), escapeshellarg($to->getPath()));
    }
365906
public function move($from, $to)
    {
        $this->clearAll();

        $from = trim($from);
        if (!$this->validatePath($from)) {
            throw new \InvalidArgumentException('Invalid source path');
        }

        $to = trim($to);
        if (!$this->validatePath($to)) {
            throw new \InvalidArgumentException('Invalid destination path');
        }

        $this->addCommandName(self::GIT_MOVE);
        $this->addCommandSubject($from);
        $this->addCommandSubject2($to);

        return $this->getCommand();
    }