Copy all the files in source directory to target.

    Ignores subdirectories.
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)
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);
        }
    }
1361940
public void copy(final File source) throws IOException {
		if (!source.exists()) {
			LOG.warn("File " + source + " cannot be copied as it does not exist");
			return;
		}
		if (equals(source)) {
			LOG.info("Skipping copying of " + source + " as it matches the target");
			return;
		}
		File target = isDirectory() ? new File(this, source.getName()) : this;
		FileUtils.copyFile(source, target);
	}
564082
def copy(self, target):
        
        shutil.copy(self.path, self._to_backend(target))
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);
        }
    }
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);
        }
    }
246497
public static void copyDirectories(String[] directories, String storageFolder) throws IOException {
        copyDirectories(getFiles(directories), storageFolder);
    }
656053
def copy(source, destination):
    
    if os.path.isdir(source):
        return __copytree(source, destination)
    else:
        return __copyfile2(source, destination)
327288
static function copyDirectory($source, $target, $overwrite = true)
    {
        $scanResult = static::scanDirectory($source);
        if (!$scanResult) return false;
        if (!is_dir($target)) self::createDirectory($target);

        try {
            $sourceRealPath = realpath($source);
            foreach ($scanResult['files'] as $file) {
                $targetRealPath = realpath($target) . '/' . ltrim(substr($file, strlen($sourceRealPath)), '/');
                static::copyFile($file, $targetRealPath, $overwrite);
            }
            return true;
        } catch (\Throwable $throwable) {
            return false;
        }
    }
1369864
public function copyFiles($source, $target, $files)
    {
        foreach ($files as $file) {
            $this->copyFile($source, $target, $file);
        }
    }
315466
def _copy_file_or_directory(self, source, destination_directory):
    
    if os.path.isdir(source):
      for item in os.listdir(source):
        full_source = os.path.join(source, item)
        full_destination = os.path.join(destination_directory, item)
        shutil.copytree(full_source, full_destination)
    else:
      shutil.copy2(source, destination_directory)
958923
private function deep_copy($source, $target_path)
    {
        // Loop through $source dir.
        $contents = \scandir($source);

        if (empty($contents)) {
            return;
        }

        foreach ($contents as $file) {
            if ('.' === $file || '..' === $file) {
                continue;
            }

            $src_path = \trailingslashit($source) . $file;
            $new_path = \trailingslashit($target_path) . $file;

            if (\is_dir($src_path)) {
                $this->mkdir($new_path);
                $this->deep_copy($src_path, $new_path);
                continue;
            }

            if ($this->file->copy($src_path, $new_path, $this->force)) {
                $this->copied[] = $new_path;
            }
        }
    }
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;
    }
1281079
public static void copyDirToDir(File source, File dest, FilenameFilter filter) throws IOException {
        if (!source.isDirectory() || !dest.isDirectory()) {
            return;
        }

        List<File> files = listFiles(source, filter, true);
        String sourcePath = source.getAbsolutePath();
        String destPath = dest.getAbsolutePath();
        for (File file : files) {
            String filePath = file.getAbsolutePath();
            if (sourcePath.equals(filePath)) {
                continue;
            }
            String newPath = destPath + File.separator + filePath.substring(sourcePath.length());
            File destFile = new File(newPath);
            if (file.isDirectory()) {
                destFile.mkdirs();
            } else {
                copy(file, destFile);
            }
        }
    }
158175
private function copyRecursive($source, $target)
    {
        if (!is_dir($source)) {
            $this->filesystem->ensureDirectoryExists(dirname($target));
            copy($source, $target);

            return;
        }

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        $this->filesystem->ensureDirectoryExists($target);

        foreach ($iterator as $file) {
            $targetPath = $target . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
            if ($file->isDir()) {
                $this->filesystem->ensureDirectoryExists($targetPath);
            } else {
                copy($file->getPathname(), $targetPath);
            }
        }
    }
748687
def copy_files(src_dir, dst_dir, filespec='*', recursive=False):
    
    import os
    from .modules import copyfiles

    if src_dir == dst_dir:
        raise RuntimeError('copy_files() src and dst directories must be different.')

    if not os.path.isdir(src_dir):
        raise RuntimeError('copy_files() src directory "{}" does not exist.'.format(src_dir))

    return {
        'dependencies_fn': copyfiles.list_files,
        'compiler_fn': copyfiles.copy_files,
        'input': src_dir,
        'output': dst_dir,
        'kwargs': {
            'filespec': filespec,
            'recursive': recursive,
        },
    }
1267439
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());
        }
        FileInputStream is = new FileInputStream(source);
        FileOutputStream os = new FileOutputStream(target);
        IOHelper.copy(is, os);
    }