Copy a file or folder to a different location in the user's Dropbox.

If the source path is a folder all its contents will be copied.

@link https://www.dropbox.com/developers/documentation/http/documentation#files-copy_v2
552235
public function copy(string $fromPath, string $toPath): array
    {
        $parameters = [
            'from_path' => $this->normalizePath($fromPath),
            'to_path' => $this->normalizePath($toPath),
        ];

        return $this->rpcEndpointRequest('files/copy_v2', $parameters);
    }
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();
                }
            }
        }
    }
237544
def copy(options)
      destination = copy_destination options
      to_path = join_paths @root_dir, destination
      to_path_exists = File.exist? to_path

      preserve_existing = false? options[:overwrite]

      copy_resource_to_path to_path, preserve_existing
      copy_pstore_to_path to_path, preserve_existing

      to_path_exists
    end
260809
public void moveFromLocalFile(Path[] srcs, Path dst)
    throws IOException {
    copyFromLocalFile(true, true, false, srcs, dst);
  }
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));
        }
    }
262083
public function copyDirectory($sourcePath, $destinationPath)
    {
        $sourceDirectory = opendir($sourcePath);

        if (! is_dir($destinationPath)) {
            self::createDirectory($destinationPath);
        }
        while (false !== ($file = readdir($sourceDirectory))) {
            if (($file !== '.') && ($file !== '..')) {
                $sourceFile = $sourcePath.'/'.$file;
                $destinationFile = $destinationPath.'/'.$file;
                if (is_dir($sourceFile)) {
                    self::copyDirectory($sourceFile, $destinationFile);
                } else {
                    self::copyFile($sourceFile, $destinationFile);
                }
            }
        }
        closedir($sourceDirectory);
    }
696790
public void moveThisFile(File fileSource, File fileDestDir, String strDestName)
    {
        fileDestDir.mkdirs();
        String strNewDir = this.getNewCalendarPath(fileSource);
        if (strNewDir != null)
        {
            fileDestDir = new File(fileDestDir, strNewDir);
            fileDestDir.mkdirs();
        }
        File fileDest = new File(fileDestDir, strDestName);
        if (fileSource.renameTo(fileDest))
            return;
        if (true)
        {
            System.out.println("Warning, system does not support move file");
            return;
        }
        super.moveThisFile(fileSource, fileDestDir, strDestName);
        if (strNewDir == null)
            return;   // Moving to a different dir = move all.
        fileSource.delete();    // Moving to the same dir (into the new directory) means delete to old file at the root
    }
122096
public void moveFromLocalFile(Path src, Path dst)
    throws IOException {
    copyFromLocalFile(true, true, false, src, dst);
  }
278009
public static boolean copyDirAndFiles(File source, File destination) {
    logger.finest(String.format("WatirUtils::copyDirAndFiles(%s, %s)", source.getAbsolutePath(),
                                destination.getAbsolutePath()));

    if (source.isDirectory()) {
      String[] items;
      items = source.list();
      for (String item : items) {
        File itemSource = new File(source.getPath(), item);
        File itemDestination = new File(destination.getPath(), item);
        boolean res = copyDirAndFiles(itemSource, itemDestination);
        if (!res) {
          logger.severe(String.format("Could not copy \"%s\" to \"%s\"",
                                      itemSource.getPath(), itemDestination.getPath()));
          return false;
        }
      }
    } else {
      try {
        Files.createParentDirs(destination);
        Files.copy(source, destination);
      } catch (IOException e) {
        logger.severe(
            String.format("Could not copy files from \"%s\" to \"%s\"",
                          source.getPath(), destination.getPath()));
        return false;
      }
    }

    return true;
  }
820700
def _copy(self, filename, destination):   # pylint: disable=no-self-use
        
        full_filename = os.path.abspath(os.path.expanduser(filename))

        if os.path.isdir(full_filename):
            shutil.copytree(full_filename, destination)
        elif os.path.isfile(full_filename):
            shutil.copyfile(full_filename, destination)
387569
public static File copy(String srcPath, String destPath, boolean isOverride) throws IORuntimeException {
		return copy(file(srcPath), file(destPath), isOverride);
	}
529799
def copyFilepath( self ):
        
        clipboard = QApplication.instance().clipboard()
        clipboard.setText(self.filepath())
        clipboard.setText(self.filepath(), clipboard.Selection)
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)
659985
public static Path copyFile(Path src, Path dest, StandardCopyOption... options) throws IORuntimeException {
		Assert.notNull(src, "Source File is null !");
		Assert.notNull(dest, "Destination File or directiory is null !");

		Path destPath = dest.toFile().isDirectory() ? dest.resolve(src.getFileName()) : dest;
		try {
			return Files.copy(src, destPath, options);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
1293963
public static void copy( Path fileOrDirectory, Path toDir )
  {
    Path copy = PathUtil.create( toDir, PathUtil.getName( fileOrDirectory ) );
    if( PathUtil.isDirectory( fileOrDirectory ) )
    {
      //noinspection ResultOfMethodCallIgnored
      try
      {
        PathUtil.mkdir( copy );
        Files.list( fileOrDirectory ).forEach( child -> copy( child, copy ) );
      }
      catch( IOException e )
      {
        throw new RuntimeException( e );
      }
    }
    else
    {
      //noinspection ResultOfMethodCallIgnored
      try( InputStream is = new BufferedInputStream( Files.newInputStream( fileOrDirectory ) );
           OutputStream os = new BufferedOutputStream( Files.newOutputStream( copy ) ) )
      {
        StreamUtil.copy( is, os );
      }
      catch( Exception e )
      {
        throw new RuntimeException( e );
      }
    }
  }
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);
                    }
                });
            });
        }
    }
655016
def file_put_contents(self, path, data):
        

        path = self.get_full_file_path(path)

        # if file exists, create a temp copy to allow rollback
        if os.path.isfile(path):
            tmp_path = self.new_tmp()
            self.do_action({
                'do'   : ['copy', path, tmp_path],
                'undo' : ['move', tmp_path, path]})

        self.do_action(
            {'do'   : ['write', path, data],
             'undo' : ['backup', path]})