Apply the uploaded file directory to be used as a destination. Specified
path starts from the project root directory. Will trim unnecessary
leading slashes.

@param string $destinationDirectory
173220
final public function setDestinationDirectory(string $destinationDirectory)
    {
        if ($destinationDirectory[strlen($destinationDirectory) - 1] != DIRECTORY_SEPARATOR) {
            $destinationDirectory .= DIRECTORY_SEPARATOR;
        }
        $this->destinationDirectory = $destinationDirectory;
    }
1355451
public void uploadDirectoryWithRetries(final String ftpServer, final String username, final String password,
                                           final String sourceDirectory, final String targetDirectory,
                                           final int maxRetryCount) throws MojoExecutionException {
        int retryCount = 0;
        while (retryCount < maxRetryCount) {
            retryCount++;
            log.info(UPLOAD_START + ftpServer);
            if (uploadDirectory(ftpServer, username, password, sourceDirectory, targetDirectory)) {
                log.info(UPLOAD_SUCCESS + ftpServer);
                return;
            } else {
                log.warn(String.format(UPLOAD_FAILURE, retryCount, maxRetryCount));
            }
        }
        // Reaching here means all retries failed.
        throw new MojoExecutionException(String.format(UPLOAD_RETRY_FAILURE, maxRetryCount));
    }
941092
public function recurse_copy($source, $destination)
    {
        $directory = opendir($source);
        $this->fs->mkdir($destination, 0755);
        while (false !== ($file = readdir($directory))) {
            if (($file != '.') && ($file != '..')) {
                if (is_dir($source . '/' . $file)) {
                    $this->recurse_copy($source . '/' . $file, $destination . '/' . $file);
                } else {
                    $this->fs->copy($source . '/' . $file, $destination . '/' . $file);
                }
            }
        }
        closedir($directory);
    }
18735
protected function makeDestination(string $destination): void
    {
        if (! $this->files->isDirectory($destination)) {
            $this->files->makeDirectory($destination, 0777, true);
        }
    }
363278
def write(site_destination_dir)
      if modified?
        Files.copy_p(path, destination(site_destination_dir))
        @is_modified = false
        true
      else
        false
      end
    end
761230
public function moveFiles(Filesystem $source, Filesystem $destination): void
    {
        foreach ($source->listContents() as $path) {
            if ($path['type'] === 'file') {
                $destination->put($path['path'], $source->read($path['path']));
                $source->delete($path['path']);

                if ($this->timeout_service->isTimeNearlyUp()) {
                    throw new InternalServerErrorException(I18N::translate('The server’s time limit has been reached.'));
                }
            }
        }
    }
749321
public function destination($path, $override_chroot = false) {
		// set the path
		$this->Destination = Filesystem::chroot($path, $override_chroot);
		// return self
		return($this);
	}
1042735
private static function buildMap(array $files, array & $destination) : void
    {
        foreach ($files as $structure) {
            foreach ($structure as $key => $value) {
                $subFiles = [];
                foreach ($files as $uploadKey => $data) {
                    $subFiles[$uploadKey] = $data[$key];
                }

                if (is_array($value)) {
                    $destination[$key] = [];
                    self::buildMap($subFiles, $destination[$key]);
                } else {
                    $destination[$key] = UploadedFile::create($subFiles);
                }
            }

            // Only one of the entries was needed to get the structure.
            break;
        }
    }
334890
def put(self, destination):
        
        if not self._fetched:
            self._fetch()
        DirectoryArchive.put(self, destination)
1023458
function MoveTo($targetFolder, $targetFilename = '')
    {
        if (!$targetFilename)
            $targetFilename = $this->Filename();
        
        $destination = Path::Combine($targetFolder, $targetFilename);
        $result = @move_uploaded_file($this->TempPath(), $destination);
        if (!$result)
            throw new \Exception('Uploaded file could not be moved to target');
    }
1267636
private function copyFrom($webroot, $path, $destination = null)
    {
        if (null === $destination) {
            $destination = $path;
            $from = $this->projectRoot . DIRECTORY_SEPARATOR . $path;
        } else {
            // if the destination was defined then we assume the path is either absolute or relative to the webroot
            // because it has been defined by the user in the extra mapping
            $from = $path;
        }

        $to = $this->projectRoot . DIRECTORY_SEPARATOR . $webroot . DIRECTORY_SEPARATOR . $destination;

        $filesystem = $this->getFilesystem();

        if ($filesystem->exists($to)) {
            $filesystem->remove($to);
        }

        $filesystem->symlink($from, $to, true);

        if ($this->io->isVerbose()) {
            $this->io->write(sprintf('Moved %s to %s', $from, $to));
        }
    }
750583
public function moveTo($destination) {
		if (!$this->isValid()) {
			return null;
		}

		$path = $this->generateFinalPath($destination);
		$moved = move_uploaded_file($this->tmpName, $path);

		if (!$moved) {
			return null;
		}

		return $path;
	}
263747
public function copy($source, $destination, $override = false)
    {
        if (is_dir($destination) && !is_dir($source)) {
            $destination = rtrim($destination, '/') . '/' . basename($source);
        }
        $this->fs->copy($source, $destination, $override);
    }
788392
public static function rmdirRecursive(string $directory): void
    {
        if (is_dir($directory)) {
            static::emptyDirectory($directory);

            if (!rmdir($directory)) {
                throw new FilesystemException("Unable to remove directory on path={$directory}");
            }
        }
    }
1128396
protected function moveNodeToDestinationPath(NodeInterface $node, $destinationPath)
    {
        $nodeData = $node->getNodeData();
        $possibleShadowedNodeData = $nodeData->move($destinationPath, $this->context->getWorkspace());
        if ($node instanceof Node) {
            $node->setNodeData($possibleShadowedNodeData);
        }
    }
1075221
public function upload($filename, $destination)
    {
        if (isset($this[$filename])) {
            $file = $this[$filename];
            if (is_uploaded_file($file[static::TMP_NAME])) {
                try {
                    return move_uploaded_file($file[static::TMP_NAME], $destination);
                } catch (\Exception $e) {
                    var_dump($e->getMessage());
                    exit();
                }
            }
        }
        return false;
    }
1426
public function copyDirectory( string $directory, string $destination, $options = null ): bool
	{
		if( !$this->isDirectory( $directory ) )
		{
			return false;
		}

		$options = $options ?: FilesystemIterator::SKIP_DOTS;

		// If the destination directory does not actually exist, we will go ahead and
		// create it recursively, which just gets the destination prepared to copy
		// the files over. Once we make the directory we'll proceed the copying.
		if( !$this->isDirectory( $destination ) )
		{
			$this->makeDirectory( $destination, 0777, true );
		}

		$items = new FilesystemIterator( $directory, $options );
		foreach( $items as $item )
		{
			// As we spin through items, we will check to see if the current file is actually
			// a directory or a file. When it is actually a directory we will need to call
			// back into this function recursively to keep copying these nested folders.
			$target = $destination . '/' . $item->getBasename();
			if( $item->isDir() )
			{
				$path = $item->getPathname();
				if( !$this->copyDirectory( $path, $target, $options ) )
				{
					return false;
				}
			}

			// If the current items is just a regular file, we will just copy this to the new
			// location and keep looping. If for some reason the copy fails we'll bail out
			// and return false, so the developer is aware that the copy process failed.
			else
			{
				if( !$this->copy( $item->getPathname(), $target ) )
				{
					return false;
				}
			}
		}

		return true;
	}