Copies files on s3 storage
@param  string $origFilePath   The name of the source bucket and key name of the source object, separated by a slash (/). Must be URL-encoded
@param  string $targetFilePath new file path
@return mixed
487446
public function copyFile($origFilePath, $targetFilePath, $publicAccess = true)
	{
		$origFilePath = str_replace('//', '/', $origFilePath);
		$targetFilePath = str_replace('//', '/', $targetFilePath);
		$result = $this->s3Client->copyObject(array(
			'Bucket' => $this->getBucket(),
			'CopySource' => $origFilePath,
			'Key'    => $targetFilePath,
			'ACL'    => $publicAccess ? self::PUBLIC_READ : self::PRIVATE_ACCESS
		));

		return $result;
	}
301925
public function download($sourceFilePath)
    {
        $result = $this->callService('GET', self::API_DOWNLOAD . base64_encode($sourceFilePath));

        return $result->getRaw();
    }
300501
public function putFile($path, $localFilePath, Config $config)
    {
        $object = $this->applyPathPrefix($path);
        $options = $this->getOptionsFromConfig($config);

        $options[OssClient::OSS_CHECK_MD5] = true;

        if (! isset($options[OssClient::OSS_CONTENT_TYPE])) {
            $options[OssClient::OSS_CONTENT_TYPE] = Util::guessMimeType($path, '');
        }

        try {
            $this->client->uploadFile($this->bucket, $object, $localFilePath, $options);
        } catch (OssException $e) {
            return false;
        }

        $type = 'file';
        $result = compact('type', 'path');
        $result['mimetype'] = $options[OssClient::OSS_CONTENT_TYPE];

        return $result;
    }
1261586
public static function listFilePaths ( $targetPath ) {
        if ( is_file($targetPath) === true ) {
            return array($targetPath);
        }

        if ( !is_dir($targetPath) || !($dh = opendir($targetPath)) ) {
            return array();
        }

        $fileList = array();
        while ( ($fileName = readdir($dh)) !== false ) {
            if ( $fileName === '.' || $fileName === '..' ) {
                continue;
            }

            $realPath = realpath($targetPath) . '/' . $fileName;

            if ( is_dir($realPath) === true ) {
                $fileList = array_merge($fileList, self::listFilePaths($realPath));
            } else {
                $fileList[] = $realPath;
            }
        }
        closedir($dh);
        sort($fileList);

        return $fileList;
    }
681204
public function baseUrl($targetPath = null)
    {
        if (!isset($this->baseUrl)) {
            throw new RuntimeException(sprintf(
                'The base URI is not defined for [%s]',
                get_class($this)
            ));
        }

        if ($targetPath !== null) {
            return $this->createAbsoluteUrl($this->baseUrl, $targetPath);
        }

        return rtrim($this->baseUrl, '/').'/';
    }
801103
public function copy($path, $newpath)
    {
        $command = $this->s3Client->getCommand(
            'copyObject',
            [
                'Bucket'     => $this->bucket,
                'Key'        => $this->applyPathPrefix($newpath),
                'CopySource' => urlencode($this->bucket . '/' . $this->applyPathPrefix($path)),
                'ACL'        => $this->getRawVisibility($path) === AdapterInterface::VISIBILITY_PUBLIC
                    ? 'public-read' : 'private',
            ] + $this->options
        );

        try {
            $this->s3Client->execute($command);
        } catch (S3Exception $e) {
            return false;
        }

        return true;
    }
277116
public function copy($path, $newpath)
    {
        $err = Qiniu_RS_Copy($this->getClient(), $this->bucket, $path, $this->bucket, $newpath);
        return $err === null;
    }
180033
public static function copy($file_path = null, $target_path = null, $force = false, array &$logs = array())
    {
        if (is_null($file_path) || is_null($target_path)) {
            return null;
        }
        if (!file_exists($file_path)) {
            $logs[] = sprintf('File path "%s" to copy was not found.', $file_path);
            return false;
        }
        $target_dir = dirname($target_path);
        $ok = (!file_exists($target_dir) && true===$force) ? Directory::create($target_dir) : true;
        if ($ok) {
            if (!file_exists($target_path) || true===$force) {
                if (copy($file_path, $target_path)) {
                    return true;
                } else {
                    $logs[] = sprintf('Can not copy file "%s" to "%s".', $file_path, $target_path);
                }
            } else {
                $logs[] = sprintf('Can not over-write target file "%s" by copy (use param `$force=true`).', $target_path);
            }
        } else {
            $logs[] = sprintf('Can not create target directory "%s" for copy.', $target_dir);
        }
        return false;
    }
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']);
        }
    }
984063
public function moveTo($targetPath)
    {
        if ($this->moved) {
            throw new RuntimeException('Uploaded file already moved');
        }

        if (! is_writable(dirname($targetPath))) {
            throw new InvalidArgumentException('Upload target path is not writable');
        }

        if (! @rename($this->file, $targetPath)) {
            throw new RuntimeException(
                sprintf('Error moving uploaded file %1s to %2s', $this->name, $targetPath)
            );
        }

        $this->moved = true;
    }
74740
def makefile(self, tarinfo, targetpath):
        
        source = self.fileobj
        source.seek(tarinfo.offset_data)
        target = bltn_open(targetpath, "wb")
        if tarinfo.sparse is not None:
            for offset, size in tarinfo.sparse:
                target.seek(offset)
                copyfileobj(source, target, size)
        else:
            copyfileobj(source, target, tarinfo.size)
        target.seek(tarinfo.size)
        target.truncate()
        target.close()
424647
public function copy(string $fromPath, string $toPath, array $mimeType) : bool
	{
		$fromPath = $this->normalizePath($fromPath);
		
		$toPath = $this->normalizePath($toPath);
		
		// If plain/text, its a folder
		if (substr($mimeType['mimetype'], 0, 4) === 'text') {
			$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/GetFolderByServerRelativeUrl(\''.$this->folderPath.$fromPath.'\')/copyTo(strNewUrl=\''.$this->folderPath.$toPath.'\', bOverWrite=true)';
		} else {
			$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/GetFileByServerRelativeUrl(\''.$this->folderPath.$fromPath.'\')/copyTo(strNewUrl=\''.$this->folderPath.$toPath.'\', bOverWrite=true)';
		}
		
		$options = [
			'headers' => $this->requestHeaders,
		];
			
		$response = $this->send('POST', $requestUrl, $options);
		
		return $response->getStatusCode() === 200 ? true : false;
	}
1346781
public static function move($sourcePath, $destinationPath)
    {
        if (!self::exists($sourcePath)) {
            throw new FileNotFoundException('Cannot find source file: ' . $sourcePath);
        }
        return rename($sourcePath, $destinationPath);
    }
1289465
public function copyTo(string $fullPath) : IFile
    {
        if ($this->copyCallback) {
            return call_user_func($this->copyCallback, $fullPath);
        }

        return $this->file;
    }
1326964
private function createDirectoryIfNotExists($absoluteTargetPath)
    {
        if (File::isDirectory($absoluteTargetPath) && File::isWritable($absoluteTargetPath)) {
            return true;
        }

        try {
            @File::makeDirectory($absoluteTargetPath, 0777, true);

            return true;
        } catch (Exception $e) {
            throw new ImageuploadException($e->getMessage());
        }
    }
251285
public function copy($oldPath, $newPath)
    {
        $url = self::BASE_URI.$this->getPathUnderRootDrive($oldPath).':/action.copy';

        $payload = $this->getNewFileLocationPayload($newPath);

        $headers = [
            'Content-Type' => 'application/json',
            'Prefer' => 'respond-async',
        ];

        $response = $this->getResponse('POST', $url, json_encode($payload), $headers);
        $asyncStatusLocation = $response->getHeader('Location');

        //check for the status of an async operation
        $completed = false;
        while (!$completed) {
            $statusResponse = $this->getResponse('GET', $asyncStatusLocation[0]);

            $statusCode = $statusResponse->getStatusCode();
            if ($statusCode == '303' || $statusCode == '200') {
                $completed = true;
            } else {
                $statusRaw = $statusResponse->getBody()->getContents();
                $status = json_decode($statusRaw);
                if ($status->status == 'failed') {
                    throw new OneDriveClientException('API error when copying the file');
                }

                //wait some time until the next status check
                sleep(0.5);
            }
        }

        return $this->getMetadata($newPath);
    }
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;
        }
    }