Copy a file(s).

@param string $path       Path to the existing file.
@param string $newpath    The new path of the file.
@param bool   $recursive  Recursive copy files.
@return bool True on success, false on failure.
336941
public static function copy(string $path, string $newpath, bool $recursive = false)
    {
        if ($recursive) {

            if (!Filesystem::has($newpath)) {
                mkdir($newpath);
            }

            $splFileInfoArr = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST);

            foreach ($splFileInfoArr as $fullPath => $splFileinfo) {
                //skip . ..
                if (in_array($splFileinfo->getBasename(), [".", ".."])) {
                    continue;
                }

                //get relative path of source file or folder
                $_path = str_replace($path, "", $splFileinfo->getPathname());

                if ($splFileinfo->isDir()) {
                    mkdir($newpath."/".$_path);
                } else {
                    copy($fullPath, $newpath."/".$_path);
                }
            }
        } else {
            return copy($path, $newpath);
        }
    }
134542
public static function copy(string $filename, string $path): bool
    {
        return @copy($filename, $path . '/' . self::basename($filename));
    }
340067
public function copy($new_path)
	{
		$info = pathinfo($this->path);
		$new_path = $this->area->get_path($new_path);

		$new_path = rtrim($new_path, '\\/').DS.$info['basename'];

		return $this->area->copy($this->path, $new_path);
	}
1002590
protected function newPath(/*# string */ $path)/*# : Path */
    {
        list($mnt, $remain) = $this->splitPath($path);
        return new Path($path, $remain, $this->getFilesystemAt($mnt));
    }
1141113
public function copy($path, $newpath)
    {
        $this->writeStream(static::normalizerPath($newpath), $this->readStream(static::normalizerPath($path))['stream'], new Config() );

        return true;
    }
359174
public function copy($src, $rel_path){
		$path = $this->setDir($rel_path);
		if( !($exist = file_exists($src)) ){
			trigger_error(sprintf('File %s doesn\'t exist.', $src), E_USER_WARNING);
		}
		return $path && $exist && copy($src, $path)
			? $path
			: false;
	}
721424
public function copy($path, $newpath)
    {
        list (, $srcId) = $this->splitPath($path);

        list ($newParentId, $fileName) = $this->splitPath($newpath);

        $file = new Google_Service_Drive_DriveFile();
        $file->setName($fileName);
        $file->setParents([
            $newParentId
        ]);

        $newFile = $this->service->files->copy($srcId, $file, $this->applyDefaultParams([
            'fields' => $this->fetchfieldsGet
        ], 'files.copy'));

        if ($newFile instanceof Google_Service_Drive_DriveFile) {
            $this->cacheFileObjects[$newFile->getId()] = $newFile;
            $this->cacheFileObjectsByName[$newParentId . '/' . $fileName] = $newFile;
            list ($newDir) = $this->splitPath($newpath);
            $newpath = (($newDir === $this->root) ? '' : ($newDir . '/')) . $newFile->getId();
            if ($this->getRawVisibility($path) === AdapterInterface::VISIBILITY_PUBLIC) {
                $this->publish($newpath);
            } else {
                $this->unPublish($newpath);
            }
            return true;
        }

        return false;
    }
410190
def copy_file(self, path):
        
        if "*" in path:
            paths = _expand_paths(path)
            if paths:
                for path in paths:
                    self._copy_file(path)
        else:
            if os.path.isfile(path):
                return self._copy_file(path)
            else:
                logger.debug("File %s does not exist", path)
                return False
58778
public function move($oldPath, $newPath)
    {
        $writeBinn = new BinnList;

        $writeBinn->addUint8(self::FSERV_MOVE);
        $writeBinn->addStr($oldPath);
        $writeBinn->addStr($newPath);
        $writeBinn->addBool(false);

        $binn = $writeBinn->serialize();

        $read = $this->writeAndReadSocket($binn);

        $readBinn = new BinnList;
        $readBinn->binnOpen($read);
        $results = $readBinn->unserialize();

        if ($results[0] != self::FSERV_STATUS_OK) {
            throw new RuntimeException('Couldn\'t move file: ' . isset($results[1]) ? $results[1] : 'Unknown');
        }

        return true;
    }
832161
public function rename($path, $newPath)
    {
        $this->recursiveCreateDir(Util::dirname($newPath));

        $location = $this->applyPathPrefix($path);
        $destination = $this->applyPathPrefix($newPath);

        try {
            $this->share->rename($location, $destination);
        } catch (NotFoundException $e) {
            return false;
        } catch (AlreadyExistsException $e) {
            return false;
        }

        return true;
    }
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);
    }
662096
public function copy($newpath)
    {
        if ($this->filesystem->copy($this->path, $newpath)) {
            return new File($this->filesystem, $newpath);
        }

        return false;
    }
379594
protected function _folder($oldPath, $newPath) {
        if (!is_dir($newPath)) {
            $oldumask = umask(0);
            mkdir($newPath, 01777); // so you get the sticky bit set 
            umask($oldumask);
        } elseif (filemtime($oldPath) < filemtime($newPath)) {
            //$this->debug($oldPath . ': ' . filemtime($oldPath). ' < ' . filemtime($newPath));
            return;
        } else {
            //$this->debug($oldPath . ': ' . filemtime($oldPath). ' > ' . filemtime($newPath));
        }
        $dir = @opendir($oldPath) or trigger_error("Unable to open original folder to copy it! ($oldPath)");
        while ($file = readdir($dir)) {
            if ($file != "." && $file != ".." && !is_dir("$oldPath/$file")) {
                copy("$oldPath/$file", "$newPath/$file");
            } elseif ($file != "." && $file != "..") {
                $this->_folder("$oldPath/$file", "$newPath/$file");
            }
        }
        closedir($dir);
    }
910061
public function moveToDirectory(string $newDirectoryPath): self
    {
        $newDirectoryPath = normalize_path($newDirectoryPath);

        if (is_dir($newDirectoryPath)) {
            if (is_writeable($newDirectoryPath)) {
                $newFolderPath = $newDirectoryPath.DIRECTORY_SEPARATOR.$this->getName();

                return $this->move($newFolderPath);
            }
            throw new FolderException('Cannot move the folder, because the directory ('.$newDirectoryPath.') is not writable',
                FolderException::NOT_WRITEABLE);
        }
        throw new FolderException('Cannot move the folder, because the directory (('.$newDirectoryPath.')) does not exist',
            FolderException::DONT_EXIST);
    }
84231
public function rename($path, $newpath)
    {
        $statusCopy = $this->copy($path, $newpath);
        $statusRemoveOld = $this->delete($path);

        return $statusCopy && $statusRemoveOld;
    }
208042
public function copy($path, $newpath)
    {
        $path = $this->applyPathPrefix($path);
        $newpath = $this->applyPathPrefix($newpath);

        $this->bucket
            ->object($path)
            ->copy($this->bucket, ['name' => $newpath]);

        return $this->bucket->object($newpath)->exists();
    }
700244
public function delete($path, $recursive = false)
    {
        $writeBinn = new BinnList;

        $writeBinn->addUint8(self::FSERV_REMOVE);
        $writeBinn->addStr($path);
        $writeBinn->addBool($recursive);

        $read = $this->writeAndReadSocket($writeBinn->serialize());

        $readBinn = new BinnList;
        $readBinn->binnOpen($read);
        $results = $readBinn->unserialize();

        if ($results[0] != self::FSERV_STATUS_OK) {
            throw new RuntimeException('Couldn\'t delete: ' . isset($results[1]) ? $results[1] : 'Unknown');
        }

        return true;
    }