本文整理汇总了PHP中League\Flysystem\Filesystem::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::copy方法的具体用法?PHP Filesystem::copy怎么用?PHP Filesystem::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::copy方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyFile
/**
* Copy file.
*
* @param string $filePath File path
* @param File $file File object
*
* @throws FileExistsException
*
* @return bool True on success, false on failure.
*/
public function copyFile($filePath, File $file)
{
try {
return $this->filesystem->copy($filePath, $file->getDirectories() . DIRECTORY_SEPARATOR . $file->getFileName());
} catch (FlysystemFileExistsException $e) {
FileExistsException::fileExists();
}
}
示例2: duplicate
/**
* Duplicate a file given it's URL
*
* @param string $url
* @return string
*/
public function duplicate($url)
{
// Make the destination path
$current_path = $this->helpers->path($url);
$filename = basename($current_path);
$dst_disk = $this->disks ? $this->disks->getFilesystem('dst') : $this->disk;
$new_path = $this->storage->makeNestedAndUniquePath($filename, $dst_disk);
// Copy, supporting alternative destination disks
if ($this->disks) {
$this->disks->copy('src://' . $current_path, 'dst://' . $new_path);
} else {
$this->disk->copy($current_path, $new_path);
}
// Return the Upchuck URL
return $this->helpers->url($new_path);
}
示例3: copy
/**
* {@inheritdoc}
*/
public function copy($source, $target)
{
if ($this->file_exists($target)) {
$this->unlink($target);
}
return $this->flysystem->copy($this->buildPath($source), $this->buildPath($target));
}
示例4: testCopy
public function testCopy()
{
$old = 'old.txt';
$new = 'new.txt';
$this->prophecy->has($old)->willReturn(true);
$this->prophecy->has($new)->willReturn(false);
$this->prophecy->copy($old, $new)->willReturn(true);
$response = $this->filesystem->copy($old, $new);
$this->assertTrue($response);
}
示例5: copy
/**
* @inheritdoc
*/
public function copy($path, $newPath)
{
$innerPath = $this->getInnerPath($path);
$newInnerPath = $this->getInnerPath($newPath);
try {
$return = $this->fileSystem->copy($innerPath, $newInnerPath);
} catch (FileNotFoundException $e) {
throw $this->exceptionWrapper($e, $path);
} catch (FileExistsException $e) {
throw $this->exceptionWrapper($e, $path);
}
if ($return !== false) {
$this->invokePlugin("addPathToIndex", [$newPath, $newInnerPath], $this);
}
return $return;
}
示例6: testCopyFail
public function testCopyFail()
{
$mock = Mockery::mock('League\\Flysystem\\AdapterInterface');
$mock->shouldReceive('write')->andReturn(array('path' => 'path.txt'));
$mock->shouldReceive('copy')->andReturn(false);
$mock->shouldReceive('has')->with('path.txt')->andReturn(false, true);
$mock->shouldReceive('has')->with('new.txt')->andReturn(false);
$filesystem = new Filesystem($mock);
$filesystem->write('path.txt', 'content');
$this->assertFalse($filesystem->copy('path.txt', 'new.txt'));
}
示例7: copy
/**
* Copy a file.
*
* @param string $path Path to the existing file.
* @param string $newpath The new path of the file.
*
* @throws FileExistsException Thrown if $newpath exists.
* @throws FileNotFoundException Thrown if $path does not exist.
*
* @return bool True on success, false on failure.
*/
public function copy($path, $newpath)
{
$result = parent::copy($path, $newpath);
if ($result && ($resource = $this->get($newpath))) {
return $this->dispatch(new SyncFile($resource));
}
return $result;
}
示例8: upRoutes
/**
* Copies the App routes into their defined location in atuin directory.
*
*/
protected function upRoutes()
{
$basePath = dirname(Yii::$app->getVendorPath());
$filesystem = new Filesystem(new Adapter($basePath));
// 1 - Move the routes into the route system in case we have those files
$fileHelper = new yii\helpers\FileHelper();
foreach ($this->arrRoutes as $type) {
$path = $this->module->basePath . '/routes/' . $type . '/';
if (is_dir($path)) {
$files = $fileHelper->findFiles($path, ['only' => ['*.php'], 'recursive' => FALSE]);
foreach ($files as $file) {
$fileName = str_replace($path, '', $file);
$from = str_replace($basePath, '', $file);
$to = '/atuin/routes/' . $type . '/app_' . $this->module->id . '_' . $fileName;
if (!$filesystem->has($to)) {
$filesystem->copy($from, $to);
}
}
}
}
}
示例9: testCreateDir
/**
* 3.txt
* 2.txt
* test/1.txt.
*/
public function testCreateDir()
{
$this->assertTrue($this->filesystem->createDir('test'));
$this->assertTrue($this->filesystem->copy('2.txt', 'test/1.txt'));
}
示例10: _copy
/**
* @inheritdoc
*/
protected function _copy($source, $target, $name)
{
return $this->fs->copy($source, $this->_joinPath($target, $name));
}
示例11: copy
/**
* Copy a file
*
* @param string $path
* @param string $newpath
* @return boolean
*/
public function copy($path, $newpath)
{
try {
return parent::copy($path, $newpath);
} catch (\Exception $e) {
$this->errors[] = $e->getMessage();
}
return false;
}