Copy a file.

@param string $path
@param string $newPath

@return bool
346107
public function copy($path, $newPath)
    {
        $result = $this->client->copyObject($this->bucket, $path, $this->bucket, $newPath);
        if (is_null($result)) {
            return false;
        }

        return true;
    }
313113
public function copy($newPath = null)
    {
        if (is_null($newPath)) {
            $newPath = $this->path . '-copy';
        }

        if (@$this->filesystem->copy($this->path, $newPath)) {
            return $this->getClone()->setPath($newPath);
        } else {
            $lastError = error_get_last();
            throw new CopyFailedException($this, $newPath, $lastError['message']);
        }
    }
12241
public function createBackup($originalPath)
    {
        // Bail if file does not exist
        if (!file_exists($originalPath)) {
            return false;
        }

        $pathinfo = pathinfo($originalPath);

        $backupPrefered = $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '.' . $pathinfo['extension'] . '.bkp';
        $backupFile = $backupPrefered;

        $i = 0;
        while (file_exists($backupFile)) {
            $i++;
            $backupFile = $backupPrefered . $i;
        }

        if (copy($originalPath, $backupFile)) {
            return $backupFile;
        }

        return false;
    }
759765
public function addAttachment($path, $newName = "")
    {
        if ($newName == "") {
            $newName = basename($path);
        }

        $file = new \stdClass();
        $file->path = $path;
        $file->name = $newName;

        $this->attachments[] = $file;

        return $this;
    }
1289465
public function copyTo(string $fullPath) : IFile
    {
        if ($this->copyCallback) {
            return call_user_func($this->copyCallback, $fullPath);
        }

        return $this->file;
    }
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);
        }
    }
1270229
public function renameOnDFS( $oldPath, $newPath )
    {
        $oldPathHandler = $this->getHandler( $oldPath );
        $newPathHandler = $this->getHandler( $newPath );

        // same handler, normal rename
        if ( $oldPathHandler === $newPathHandler )
        {
            return $oldPathHandler->renameOnDFS( $oldPath, $newPath );
        }
        // different handlers, create on new, delete on old
        else
        {
            if ( $newPathHandler->createFileOnDFS( $newPath, $oldPathHandler->getContents( $oldPath ) ) !== true )
                return false;

            return $oldPathHandler->delete( $oldPath );
        }
    }
1339518
public function copyFile($originalFile, $newFile)
    {
        if (is_file($originalFile)) {
            @copy($originalFile, $newFile) or die("File '{$originalFile}' can't be copied to '{$newFile}'.");
        } else {
            die("File '{$originalFile}' doesn't exist.");
        }
    }
165143
public static function move($path, $target, $fileName, $encryption = false, $newFilename = false)
    {
        $fileNameOld    = $fileName;
        $extension      = File::extension($fileName);
        $baseName       = basename($fileName, '.' . $extension);

        if ($encryption)
        {
            mt_srand();
            $fileName = md5(uniqid(mt_rand())) . "." . $extension;
        }
        elseif ($newFilename)
        {
            $fileName = $newFilename . "." . $extension;
        }

        $i = 0;
        while (File::exists($target . '/' . $fileName))
        {
            $i++;
            $fileName = $baseName . '-' . $i . '.' . $extension;
        }
        
        File::move($path . '/' . $fileNameOld, $target . '/' . $fileName);

        return $fileName;
    }
1078098
public function copy($path, $newpath)
    {
        $location = $this->applyPathPrefix($path);
        $destination = $this->applyPathPrefix($newpath);
        $this->ossClient->copyObject($this->bucket, $location, $this->bucket, $destination);
        return true;
    }
885044
public function copy($path, $newpath)
    {
        $response = $this->readStream($path);

        if ($response === false || ! is_resource($response['stream'])) {
            return false;
        }

        $result = $this->writeStream($newpath, $response['stream'], new Config());

        if ($result !== false && is_resource($response['stream'])) {
            fclose($response['stream']);
        }

        return $result !== false;
    }
513466
public function moveFile($oldPath, $newPath, $isRename = false)
    {
        $oldPath = self::validatePath($oldPath);
        $fullOldPath = $this->getMediaPath($oldPath);

        $newPath = self::validatePath($newPath);
        $fullNewPath = $this->getMediaPath($newPath);

        return $this->getStorageDisk()->move($fullOldPath, $fullNewPath);
    }
662096
public function copy($newpath)
    {
        if ($this->filesystem->copy($this->path, $newpath)) {
            return new File($this->filesystem, $newpath);
        }

        return false;
    }
974327
public function rename($path, $newpath)
    {
        $location = $this->applyPathPrefix($path);
        $destination = $this->applyPathPrefix($newpath);
        $this->ossClient->copyObject($this->bucket, $location, $this->bucket, $destination);
        $this->ossClient->deleteObject($this->bucket, $location);
        return true;
    }
973243
public function rename($path, $newpath)
    {
        $newpath = static::normalizerPath($newpath);

        $this->writeStream($newpath, $this->readStream($path)['stream'], new Config() );

        $this->delete($path);

        return true;
    }
883312
public static function copyFile($filename, $newfilename)
    {
        if (!is_file($filename) || !is_writable($filename)) return false;
            self::createDir(dirname($newfilename)); //创建目录
        return copy($filename, $newfilename);
    }
160720
public function copyContent(string $newFolderPath): self
    {
        $newFolderPath = normalize_path($newFolderPath);

        if (is_dir($newFolderPath)) {
            if (recursive_copy($this->getPath(), $newFolderPath)) {
                return self::load($newFolderPath);
            }
        }
        throw new FolderException('Cannot copy folder content, because the destination folder path ('.$newFolderPath.') does not exist',
            FolderException::DONT_EXIST);
    }