Copy file.

@param (string) $source Name of file or directory with path.
@param (string) $target Target directory.
@param (string) $files  Files to be copy.

@since 3.0.0

@return void
779560
public function copyFile($source, $target, $file)
    {
        $this->mkDir($target);
        if (file_exists($source.$file)) {
            copy($source.$file, $target.$file);
        }
    }
685777
private function symlink($source, $target)
	{
		if (file_exists($target))
		{
			if (is_dir($target))
			{
				$this->_deleteDir($target);
			}
			else
			{
				unlink($target);
			}
		}

		try
		{
			$this->taskFileSystemStack()
				->symlink($source, $target)
				->run();
		}
		catch (Exception $e)
		{
			$this->say('Error symlinking: ' . $e->message());
		}
	}
178181
public static function move($source, $target)
    {
        if (!file_exists($source) || !is_dir($source)) {
            // Rename fails if source folder does not exist.
            throw new \RuntimeException('Cannot move non-existing folder.');
        }

        // Don't do anything if the source is the same as the new target
        if ($source === $target) {
            return;
        }

        if (file_exists($target)) {
            // Rename fails if target folder exists.
            throw new \RuntimeException('Cannot move files to existing folder/file.');
        }

        // Make sure that path to the target exists before moving.
        self::create(dirname($target));

        // Silence warnings (chmod failed etc).
        @rename($source, $target);

        // Rename function can fail while still succeeding, so let's check if the folder exists.
        if (!file_exists($target) || !is_dir($target)) {
            // In some rare cases rename() creates file, not a folder. Get rid of it.
            if (file_exists($target)) {
                @unlink($target);
            }
            // Rename doesn't support moving folders across filesystems. Use copy instead.
            self::copy($source, $target);
            self::delete($source);
        }

        // Make sure that the change will be detected when caching.
        @touch(dirname($source));
        @touch(dirname($target));
        @touch($target);
    }
154563
public function copy($source, $target)
    {
        if (!is_dir($source)) {
            return copy($source, $target);
        }
        $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
        /** @var RecursiveDirectoryIterator $ri */
        $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
        $this->filesystem->ensureDirectoryExists($target);
        $result = true;
        foreach ($ri as $file) {
            $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
            if ($file->isDir()) {
                $this->filesystem->ensureDirectoryExists($targetPath);
            } else {
                $result = $result && copy($file->getPathname(), $targetPath);
            }
        }
        return $result;
    }
945756
public function copy($target) {
        if (!parent::copy($target))
            return false;
        return file_put_contents($target, $this->content) !== false;
    }
556956
public function copyDir($source, $target, $dir)
    {
        $this->mkDir($target);
        $serverOs = (new \Zest\Common\OperatingSystem())->get();
        $command = ($serverOs === 'Windows') ? 'xcopy ' : 'cp -r ';
        if (is_dir($source.$dir)) {
            shell_exec($command.$source.$dir.' '.$target);
        }
    }
348437
public static void copy(File source, File target) throws IOException {
        if (!source.exists()) {
            throw new FileNotFoundException("Source file not found:" + source.getAbsolutePath());
        }

        if (!target.exists() && !target.getParentFile().exists() && !target.getParentFile().mkdirs()) {
            throw new IOException("Can't create target directory:" + target.getParentFile().getAbsolutePath());
        }
        if (source.isDirectory()) {
            target.mkdirs();
            File[] files = source.listFiles();
            if (files != null) {
                for (File child : files) {
                    copy(child, new File(target, child.getName()));
                }
            }
        } else {
            FileInputStream is = new FileInputStream(source);
            FileOutputStream os = new FileOutputStream(target);
            io.fabric8.utils.Files.copy(is, os);
        }
    }
794980
private function copy(string $source, string $target): int
    {
        if (!@copy($source, $target)) {
            $message = 'Could not copy file.';
            if ($error = error_get_last()) {
                $message .= sprintf(' Errno: %d; %s', $error['type'], $error['message']);
            }
            throw new FileException($message);
        }

        return $this->stat($target)['size'];
    }
357994
public static final void copyResource(String source, Path target, Class<?> cls) throws IOException
    {
        try (InputStream is = cls.getResourceAsStream(source))
        {
            Files.copy(is, target, REPLACE_EXISTING);
        }
    }
167642
public static function copy($source, $target)
    {
        $source = Normalize::diskFullPath($source);
        $target = Normalize::diskFullPath($target);

        // check if target directory exist & create new if not
        $targetArray = explode(DIRECTORY_SEPARATOR, $target);
        array_pop($targetArray);
        $targetDir = implode(DIRECTORY_SEPARATOR, $targetArray);
        if (!Directory::exist($targetDir)) {
            Directory::create($targetDir, 0777);
        }

        return copy($source, $target);
    }
498453
def _copy_files(source, target):
    
    source_files = listdir(source)
    if not exists(target):
        makedirs(target)
    for filename in source_files:
        full_filename = join(source, filename)
        if isfile(full_filename):
            shutil.copy(full_filename, target)
67999
protected function copyConfigurationFile($source, $target)
    {
        $fs = new Filesystem();
        $fs->copy($source, $target, true);

        if (!$this->output->isQuiet()) {
            $this->output->writeln("Copied $source to $target");
        }
    }
127571
public function copyDirectory(string $source, string $target, int $flags = null) : bool
    {
        if (!$this->exists($source)) {
            return false;
        }

        if (!$this->isDirectory($target) && !$this->makeDirectory($target, 0777, true)) {
            return false;
        }

        if ($flags === null) {
            $flags = FilesystemIterator::SKIP_DOTS;
        }

        $items = new FilesystemIterator($source, $flags);

        foreach ($items as $item) {
            if ($item->isDir()) {
                if (!$this->copyDirectory($item->getRealPath(), $target . '/' . $item->getBasename(), $flags)) {
                    return false;
                }
            } elseif ($item->isFile()) {
                if (!$this->copyFile($item->getRealPath(), $target . '/' . $item->getBasename())) {
                    return false;
                }
            }
        }

        return true;
    }
1267230
public static function copyFile($source, $path)
    {
        $path = str_replace('\\', '/', $path);
        $arr = explode('/', $path);
        array_pop($arr);
        $folder = join('/', $arr);
        if (!is_dir($folder)) {
            self::createFolder($folder);
        }
        if (is_file($source)) {
            copy($source, $path);
        }
    }
1265457
def copy_files(source_files, target_directory, source_directory=None):
    """"""
    try:
        os.makedirs(target_directory)
    except:     # TODO: specific exception?
        pass
    for f in source_files:
        source = os.path.join(source_directory, f) if source_directory else f
        target = os.path.join(target_directory, f)
        shutil.copy2(source, target)
1300314
public static function copyFile(string $source, string $dest)
    {
        $dir = dirname($dest);
        if (!is_dir($dir)) {
            mkdir($dir, 0700, true);
        }
        copy($source, $dest);
    }
25112
public static void copyDirectory(File sourceLocation, File targetLocation) throws IOException {

        if (sourceLocation.isDirectory()) {
            if (!targetLocation.exists()) {
                if (targetLocation.mkdir() == false) {
                    logger.debug("Creating target directory " + targetLocation + " failed.");
                }
            }

            String[] children = sourceLocation.list();
            if (children == null) {
                return;
            }

            for (int i = 0; i < children.length; i++) {
                copyDirectory(new File(sourceLocation, children[i]), new File(targetLocation, children[i]));
            }
        } else {
            FileInputStream in = null;
            FileOutputStream out = null;
            try {
                in = new FileInputStream(sourceLocation);
                out = new FileOutputStream(targetLocation);
                copyStream(in, out);
            } finally {
                if (in != null) {
                    in.close();
                }
                if (out != null) {
                    out.close();
                }
            }
        }
    }