Copy a directory from one location to another.

@param  string $directory
@param  string $destination
@param  int $options
@return bool
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;
	}
59455
public static function copyResources($sourceDirectory, $destinationDirectory, $excludeFiles = array()){
        //copy the resources
        $exclude = array_merge($excludeFiles, array('.', '..', '.svn'));
        $success = true;
        foreach(scandir($sourceDirectory) as $file){
            if(!in_array($file, $exclude)){
                $success &= tao_helpers_File::copy(
                    $sourceDirectory.$file, $destinationDirectory.$file, true
                );
            }
        }
        return $success;
    }
1354174
public function mkdir($url, $mode, $options)
  {
    $partition = self::getPartition($url);
    $path = self::getRelativePath($url);

    return !!$partition->makeDirectory($path, $mode, $options);
  }
44265
public static void copyDirectories(String[] directories, String[] destinationDirectories) throws IOException {
        copyDirectories(getFiles(directories), getFiles(destinationDirectories));
    }
1303894
public function rmdir($path, $options)
    {
        $dir = $this->dir_list($path);

        if (empty($dir)) {
            $count = count(self::$folders);
            for ($index = 0; index < $count; $index++) {
                if (self::$folders[$index] === $path) {
                    unset(self::$folders[$index]);
                    return true;
                }
            }
        }

        return false;
    }
105423
public function copy($destination) {
		$destination = $this->getDestination($destination);

		if (!@copy($this->getPathname(), $destination)) {
			throw new FileException(sprintf('Failed to copy %s to %s', $this->pathname, $destination));
		}
	}
1367718
public function copy(string $destination, $overwrite = false) : bool
    {
        $copied = false;

        if ($this->isFile()) {
            $exists = file_exists($destination);
            if (!$exists || ($exists && $overwrite)) {
                $copied = copy($this->realPath, $destination);
            }
        }

        return $copied;
    }
388330
public static void copyDirectories(File[] directories, File[] destinationDirectories) throws IOException {
        int length = Integer.min(directories.length, destinationDirectories.length);
        for (int i = 0; i < length; i++) {
            copyDirectory(directories[i], destinationDirectories[i]);
        }
    }
77725
private function copyFile(
        FilesystemInterface $source,
        FilesystemInterface $destination,
        $path
    ) {
        $destination->put(
            $path,
            $source->read($path)
        );
    }
27610
static function copy( $sourceFilename, $destinationFilename )
    {
        if ( is_dir( $sourceFilename ) )
        {
            eZDebug::writeError( "Unable to copy directory $sourceFilename, use eZDir::copy instead", __METHOD__ );
            return false;
        }
        $sourceFD = @fopen( $sourceFilename, 'rb' );
        if ( !$sourceFD )
        {
            eZDebug::writeError( "Unable to open source file $sourceFilename in read mode", __METHOD__ );
            return false;
        }
        if ( is_dir( $destinationFilename ) )
        {
            $dirPosition = strrpos( $sourceFilename, '/' );
            $filePosition = 0;
            if ( $dirPosition !== false )
                $filePosition = $dirPosition + 1;
            if ( strlen( $destinationFilename ) > 0 and
                 $destinationFilename[strlen( $destinationFilename ) - 1] == '/' )
                $destinationFilename .= substr( $sourceFilename, $filePosition );
            else
                $destinationFilename .= '/' . substr( $sourceFilename, $filePosition );
        }

        // If source and destination are the same files we just return true
        if ( $sourceFilename == $destinationFilename )
        {
            @fclose( $sourceFD );
            return true;
        }

        $destinationFD = fopen( $destinationFilename, 'wb' );
        chmod( $destinationFilename, octdec( eZINI::instance()->variable( 'FileSettings', 'StorageFilePermissions' ) ) );
        if ( !$destinationFD )
        {
            @fclose( $sourceFD );
            eZDebug::writeError( "Unable to open destination file $destinationFilename in write mode", __METHOD__ );
            return false;
        }
        $bytesCopied = 0;
        do
        {
            $data = fread( $sourceFD, 4096 );
            if ( strlen( $data ) == 0 )
                break;
            fwrite( $destinationFD, $data );
            $bytesCopied += strlen( $data );
        } while( true );

        @fclose( $sourceFD );
        @fclose( $destinationFD );
        return true;
    }
1088964
public function copy($destination) {
    
    if (!$this->exists()) {
      throw new Exception('Source from copy does not exist: '.$this);
    }
    
    if ($destination instanceof Dir) {
      $destination = $destination->getFile($this->getName());
    } elseif (!($destination instanceof File)) {
      throw new InvalidArgumentException('Invalid Argument. $destination must be file or dir');
    }

    if (!$destination->getDirectory()->exists()) {
      throw new Exception('The directory from the destination file does not exist: '.$destination);
    }

    $ret = @copy((string) $this, (string) $destination);

    if (!$ret) {
      throw new Exception('PHP Error while copying '.$this.' onto '.$destination);
    }
    
    return $this;
  }
56258
function copy(inputdir, outputdir, options) {
	const _options = Object.assign({ dir: '.' }, options);
	fsPlus.copySync(path.join(inputdir, _options.dir), outputdir);
	return Promise.resolve();
}
918206
def copy(destination: site.path, mirror: false)
      fail 'Must specify a destination' if destination.nil?
      exclude = options[:copy_exclude]
      exclude.concat config[:persistent] unless config[:persistent].nil?
      Utils.copy_directory directory, destination, exclude: exclude, mirror: mirror
      self
    end
756526
public function download($url, $directory)
    {
        coollect((array) $url)->each(function ($url) use ($directory) {
            $filename = basename($url);

            $destination = $this->toDir("{$directory}/{$filename}");

            $this->message("Downloading to {$destination}");

            $this->mkDir($directory);

            $this->downloadFile($url, $destination);
        });
    }
449242
private function getFileFromDisk($directory, $source)
    {
        $hash = 'DISK-'.\md5(\realpath($source));
        if (!\array_key_exists($hash, $this->files)) {
            // Check if source is a directory or a file.
            if (\is_dir($source)) {
                $this->fs->mirror($source, $directory.'/'.$hash, null, ['copy_on_windows' => true]);
            } else {
                $this->fs->copy($source, $directory.'/'.$hash);
            }

            $this->files[$hash] = $hash;
        }

        return $this->files[$hash];
    }
363680
private function deleteDirectories(Directory $path, array $options = array())
    {
        foreach ($this->manager->findDirectories($path) as $dir) {
            $this->delete($dir, $options);
        }
    }
248331
public function mkdir(string $url, int $mode, int $options): bool
    {
        $partition = self::getPartition($url);
        $path = self::getRelativePath($url);

        return (bool) $partition->makeDirectory($path, $mode, $options);
    }