Copy file or directory to the destination tree. If a directory, then
        everything below it is recursively copied. A list of copied files are
        saved for use later in preparing a report.
512915
def _do_copy_path(self, srcpath, dest=None):
        '''
        '''
        if self._is_forbidden_path(srcpath):
            self._log_debug("skipping forbidden path '%s'" % srcpath)
            return ''

        if not dest:
            dest = srcpath

        if self.use_sysroot():
            dest = self.strip_sysroot(dest)

        try:
            st = os.lstat(srcpath)
        except (OSError, IOError):
            self._log_info("failed to stat '%s'" % srcpath)
            return

        if stat.S_ISLNK(st.st_mode):
            self._copy_symlink(srcpath)
            return
        else:
            if stat.S_ISDIR(st.st_mode) and os.access(srcpath, os.R_OK):
                self._copy_dir(srcpath)
                return

        # handle special nodes (block, char, fifo, socket)
        if not (stat.S_ISREG(st.st_mode) or stat.S_ISDIR(st.st_mode)):
            ntype = _node_type(st)
            self._log_debug("creating %s node at archive:'%s'"
                            % (ntype, dest))
            self._copy_node(srcpath, st)
            return

        # if we get here, it's definitely a regular file (not a symlink or dir)
        self._log_debug("copying path '%s' to archive:'%s'" % (srcpath, dest))

        # if not readable(srcpath)
        if not st.st_mode & 0o444:
            # FIXME: reflect permissions in archive
            self.archive.add_string("", dest)
        else:
            self.archive.add_file(srcpath, dest)

        self.copied_files.append({
            'srcpath': srcpath,
            'dstpath': dest,
            'symlink': "no"
        })
389121
def move(self, source, destination):
        
        if source.isfile():
            source.copy(destination)
            source.remove()
        else:
            source.copy(destination, recursive=True)
            source.remove('r')
1329278
def copy_all_files_and_subfolders(src, dest, base_path_ignore, xtn_list):
	
	ensure_dir(dest)
	fl = mod_fl.FileList([src], xtn_list, exclude_folders,  '')
	all_paths = fl.get_list_of_paths()
	fl.save_filelist(os.path.join(dest,'files_backed_up.csv'),  ["name", "path", "size", "date"])
	
	for p in all_paths:
		dest_folder = os.path.join(dest, p[len(base_path_ignore):])
		ensure_dir(dest_folder)
		#print('copying ' + p)
		copy_files_to_folder(p, dest_folder, xtn='*')
656053
def copy(source, destination):
    
    if os.path.isdir(source):
        return __copytree(source, destination)
    else:
        return __copyfile2(source, destination)
293337
function copyFile(srcPath, destPath) {
        let srcFileInfo = path.parse(srcPath) || {};
        if (!path.extname(destPath) && srcFileInfo.ext) {
            // destination is a directory!
            return copyFileIntoDirectory(srcPath, destPath);
        } else {
            return new Promise(function (resolve, reject) {
                fs.copy(srcPath, destPath, function (err) {
                    if (!err) {
                        resolve();
                    } else {
                        reject(err);
                    }
                });
            });
        }
    }
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();
                }
            }
        }
    }
172046
function copyFiles(dir) {
    var files = fs.readdirSync(srcDir + dir);
    files.forEach(function(file) {
      var currentDir = dir + file;
      if (!regexExcludeFiles.test(currentDir)) {
        var stats = fs.statSync(srcDir + currentDir);
        if (stats.isDirectory()) {
          if (!fs.existsSync(publishDir + currentDir)) {
            fs.mkdirSync(publishDir + currentDir);
          }
          copyFiles(currentDir + "/");
        } else if (stats.isFile()) {
          var contents = fs.readFileSync(srcDir + currentDir);
          fs.writeFileSync(publishDir + currentDir, contents);
        }
      }
    });
  }
73212
def recursive_hardlink_dirs(source_d, destination_d):
    '''
    
    '''
    func = os.link
    if os.name == 'nt':
        func = shutil.copy
    if os.path.exists(destination_d):
        os.rmdir(destination_d)
    shutil.copytree(source_d, destination_d, copy_function=func)
1171389
def _copy_folder_and_get_directory_listings(
            self):
        
        self.log.info(
            'starting the ``_copy_folder_and_get_directory_listings`` method')

        # COPY TEMPLATE STRUCTURE TO /tmp/
        basename = os.path.basename(self.pathToTemplate)
        tmpPath = "/tmp/%(basename)s" % locals()
        try:
            shutil.rmtree(tmpPath)
        except:
            pass
        shutil.copytree(self.pathToTemplate, tmpPath)

        directoryContents = recursive_directory_listing(
            log=self.log,
            baseFolderPath=tmpPath,
            whatToList="all"  # all | files | dirs
        )

        self.directoryContents = directoryContents
        self.tmpPath = tmpPath

        self.log.info(
            'completed the ``_copy_folder_and_get_directory_listings`` method')
        return None
803157
def copy_to(_, directory)
      # Delete the directory to make sure no pervious version remains
      FileUtils.rm_rf(directory) if directory.exist?

      # Create parent directory
      FileUtils.mkdir_p(directory.parent)

      # Create symlink
      FileUtils.ln_s(@dir.expand_path, directory)

      nil
    end
789786
def copy_directory(src, dest, force=False):
    ''' 
    '''
    if os.path.exists(dest) and force is True:
        shutil.rmtree(dest)

    try:
        shutil.copytree(src, dest)
    except OSError as e:
        # If the error was caused because the source wasn't a directory
        if e.errno == errno.ENOTDIR:
            shutil.copy(src, dest)
        else:
            bot.error('Directory not copied. Error: %s' % e)
            sys.exit(1)
653391
public static void recursivelyCopyDirectory(final File sourceDir, final File destDir,
      final StandardCopyOption copyOption)
      throws IOException {
    checkNotNull(sourceDir);
    checkNotNull(destDir);
    checkArgument(sourceDir.isDirectory(), "Source directory does not exist");
    java.nio.file.Files.createDirectories(destDir.toPath());
    walkFileTree(sourceDir.toPath(), new CopyFileVisitor(sourceDir.toPath(), destDir.toPath(),
        copyOption));
  }
1239842
def copy(self, dest):
        
        if os.path.isfile(self.path):
            shutil.copy2(self.path, dest)
        else:
            shutil.copytree(self.path, dest, symlinks=False, ignore=None)
44265
public static void copyDirectories(String[] directories, String[] destinationDirectories) throws IOException {
        copyDirectories(getFiles(directories), getFiles(destinationDirectories));
    }
993481
public static void copyDirs(Path source, Path target, CopyOption... options) throws IOException {
        if (Files.notExists(target)) {
            Files.createDirectory(target);
        }

        logger.debug("  --> Copying resources from [{}]", source);
        if (Files.notExists(source)) {
            throw new RuntimeException(source + " doesn't seem to exist.");
        }

        Files.walkFileTree(source, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE,
                new InternalFileVisitor(source, target, options));

        logger.debug("  --> Resources ready in [{}]", target);
    }
1248965
function copyFile (src, done) {
        var dest = path.join(outdir, path.relative(compiler.dirname, src))
        var dirname = utils.dirname(dest)

        if (dirname === dest) {
          copy(src, dest, compiler.dirname, done)
        } else {
          mkdirp(dirname, function (err) {
            if (err) return done(err)
            copy(src, dest, compiler.dirname, done)
          })
        }
      }
726174
def copy(source, destination):
    

    try:
        if os.path.isfile(source):
            LOGGER.debug("> Copying '{0}' file to '{1}'.".format(source, destination))
            shutil.copyfile(source, destination)
        else:
            LOGGER.debug("> Copying '{0}' directory to '{1}'.".format(source, destination))
            shutil.copytree(source, destination)
        return True
    except Exception as error:
        raise foundations.exceptions.PathCopyError(
            "!> {0} | Cannot copy '{1}' path: '{2}'".format(__name__, source, error))