当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::rename方法代码示例

本文整理汇总了PHP中League\Flysystem\Filesystem::rename方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::rename方法的具体用法?PHP Filesystem::rename怎么用?PHP Filesystem::rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在League\Flysystem\Filesystem的用法示例。


在下文中一共展示了Filesystem::rename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testWrite

 /**
  * @dataProvider filesystemProvider
  */
 public function testWrite(Filesystem $filesystem, $adapter, $cache)
 {
     $this->assertTrue($filesystem->write('some_file.txt', 'some content'));
     $this->assertTrue($filesystem->has('some_file.txt'));
     $this->assertTrue($cache->has('some_file.txt'));
     $this->assertTrue($adapter->has('some_file.txt'));
     $this->assertCount(1, $filesystem->listContents());
     $this->assertCount(1, $cache->listContents('', false));
     $this->assertCount(1, $adapter->listContents('', false));
     $filesystem->rename('some_file.txt', 'other_name.txt');
     $this->assertFalse($filesystem->has('some_file.txt'));
     $this->assertFalse($cache->has('some_file.txt'));
     $this->assertFalse($adapter->has('some_file.txt'));
     $this->assertTrue($filesystem->has('other_name.txt'));
     $this->assertTrue($cache->has('other_name.txt'));
     $this->assertTrue($adapter->has('other_name.txt'));
     $this->assertCount(1, $filesystem->listContents());
     $this->assertCount(1, $cache->listContents('', false));
     $this->assertCount(1, $adapter->listContents('', false));
     $filesystem->delete('other_name.txt');
     $this->assertFalse($filesystem->has('other_name.txt'));
     $this->assertFalse($cache->has('other_name.txt'));
     $this->assertFalse($adapter->has('other_name.txt'));
     $this->assertCount(0, $filesystem->listContents());
     $this->assertCount(0, $cache->listContents('', false));
     $this->assertCount(0, $adapter->listContents('', false));
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:30,代码来源:FilesystemTests.php

示例2: rename

 /**
  * {@inheritdoc}
  */
 public function rename($source, $target)
 {
     if ($this->file_exists($target)) {
         $this->unlink($target);
     }
     return $this->flysystem->rename($this->buildPath($source), $this->buildPath($target));
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:10,代码来源:Flysystem.php

示例3: _move

 /**
  * @inheritdoc
  */
 protected function _move($source, $target, $name)
 {
     $path = $this->_joinPath($target, $name);
     if ($this->fs->rename($source, $path)) {
         return $path;
     }
     return false;
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:11,代码来源:FlysystemDriver.php

示例4: moveToRepo

 /**
  * @param $sourceFile
  * @param $repoFile
  *
  * @return bool
  *
  */
 public function moveToRepo($sourceFile, $repoFile)
 {
     $filesystem = new Filesystem(new Adapter('/'));
     if ($filesystem->has($repoFile)) {
         $filesystem->delete($repoFile);
     }
     $result = $filesystem->rename($sourceFile, $repoFile);
     unset($filesystem);
     return $result;
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:17,代码来源:myWebRequest.class.php

示例5: testRename

 public function testRename()
 {
     $old = 'old.txt';
     $new = 'new.txt';
     $this->prophecy->has($old)->willReturn(true);
     $this->prophecy->has($new)->willReturn(false);
     $this->prophecy->rename($old, $new)->willReturn(true);
     $response = $this->filesystem->rename($old, $new);
     $this->assertTrue($response);
 }
开发者ID:mechiko,项目名称:staff-october,代码行数:10,代码来源:FilesystemTests.php

示例6: rename

 /**
  * @inheritdoc
  */
 public function rename($path, $newPath)
 {
     $innerPath = $this->getInnerPath($path);
     $newInnerPath = $this->getInnerPath($newPath);
     try {
         $return = $this->fileSystem->rename($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);
         $this->invokePlugin("removePathFromIndex", [$path, $innerPath], $this);
     }
     return $return;
 }
开发者ID:petrknap,项目名称:php-filestorage,代码行数:20,代码来源:FileSystem.php

示例7: renameLessonsWithRightPadding

 /**
  * Rename lessons, adding 0 padding to the number.
  */
 public function renameLessonsWithRightPadding()
 {
     $list = $this->system->listContents(LESSONS_FOLDER);
     foreach ($list as $entry) {
         if ($entry['type'] != 'file') {
             continue;
         }
         $originalName = $entry['basename'];
         $oldNumber = substr($originalName, 0, strpos($originalName, '-'));
         if (strlen($oldNumber) == 4) {
             continue;
         }
         // already correct
         $newNumber = sprintf("%04d", $oldNumber);
         $nameWithoutNumber = substr($originalName, strpos($originalName, '-') + 1);
         $newName = $newNumber . '-' . $nameWithoutNumber;
         $this->system->rename(LESSONS_FOLDER . '/' . $originalName, LESSONS_FOLDER . '/' . $newName);
     }
 }
开发者ID:HarryBosh,项目名称:laracasts-downloader,代码行数:22,代码来源:Controller.php

示例8: save

 /**
  * @param File[] $files
  *
  * @throws CanNotSavedException
  *
  * @return File[]
  */
 public function save($files)
 {
     $fileSystemAdapter = $this->getAdapter();
     $fileSystem = new Filesystem($fileSystemAdapter);
     $savedFiles = [];
     $i = 0;
     foreach ($files as $file) {
         $i++;
         $filePath = $this->fileNameResolver->resolve(new \DateTime('now', new \DateTimeZone('UTC')), 'database', $file->getExtension());
         $newBackupLocation = $this->backupFolder . '/' . $filePath;
         $currBackupLocation = $file->getPath();
         if ($fileSystem->has($newBackupLocation)) {
             $fileSystem->delete($newBackupLocation);
         }
         if (!$fileSystem->rename($currBackupLocation, $newBackupLocation)) {
             throw new CanNotSavedException();
         }
         $savedFiles[] = new File($fileSystemAdapter->applyPathPrefix($newBackupLocation));
     }
     return $savedFiles;
 }
开发者ID:Viscaweb,项目名称:EasyBackups,代码行数:28,代码来源:FileSystemSaver.php

示例9: assembleChunks

 public function assembleChunks($chunks, $removeChunk, $renameChunk)
 {
     // the index is only added to be in sync with the filesystem storage
     $path = $this->prefix . '/' . $this->unhandledChunk['uuid'] . '/';
     $filename = $this->unhandledChunk['index'] . '_' . $this->unhandledChunk['original'];
     if (empty($chunks)) {
         $target = $filename;
     } else {
         sort($chunks, SORT_STRING | SORT_FLAG_CASE);
         $target = pathinfo($chunks[0], PATHINFO_BASENAME);
     }
     if ($this->unhandledChunk['index'] === 0) {
         // if it's the first chunk overwrite the already existing part
         // to avoid appending to earlier failed uploads
         $handle = fopen($path . '/' . $target, 'w');
     } else {
         $handle = fopen($path . '/' . $target, 'a');
     }
     $this->filesystem->putStream($path . $target, $handle);
     if ($renameChunk) {
         $name = preg_replace('/^(\\d+)_/', '', $target);
         /* The name can only match if the same user in the same session is
          * trying to upload a file under the same name AND the previous upload failed,
          * somewhere between this function, and the cleanup call. If that happened
          * the previous file is unaccessible by the user, but if it is not removed
          * it will block the user from trying to re-upload it.
          */
         if ($this->filesystem->has($path . $name)) {
             $this->filesystem->delete($path . $name);
         }
         $this->filesystem->rename($path . $target, $path . $name);
         $target = $name;
     }
     $uploaded = $this->filesystem->get($path . $target);
     if (!$renameChunk) {
         return $uploaded;
     }
     return new FlysystemFile($uploaded, $this->filesystem, $this->streamWrapperPrefix);
 }
开发者ID:BboyKeen,项目名称:OneupUploaderBundle,代码行数:39,代码来源:FlysystemStorage.php

示例10: rename

 /**
  * Renames the object for a given path.
  *
  * @param string $path
  * @param string $newpath
  *
  * @return bool `true` on success, `false` on failure.
  */
 public function rename($path, $newpath)
 {
     $baseAdapter = $this->getBaseAdapter();
     if ($baseAdapter instanceof EmulateRenameDirectoryInterface && $this->hasDirectory($path)) {
         return $baseAdapter->renameDirectory($path, $newpath);
     }
     return parent::rename($path, $newpath);
 }
开发者ID:mat33470,项目名称:PFA,代码行数:16,代码来源:Backend.php

示例11: move

 /**
  * Move a file to a new location.
  *
  * @param  string  $from
  * @param  string  $to
  * @return bool
  */
 public function move($from, $to)
 {
     return parent::rename($from, $to);
 }
开发者ID:weyii,项目名称:yii2-filesystem,代码行数:11,代码来源:Filesystem.php

示例12: rename

 /**
  * @param string $path
  * @param string $newPath
  *
  * @return bool
  */
 public function rename($path, $newPath)
 {
     return $this->filesystem->rename($path, $newPath);
 }
开发者ID:da-vinci-studio,项目名称:file-bundle,代码行数:10,代码来源:Local.php

示例13: testRename

 /**
  * 3.txt
  * 2.txt.
  */
 public function testRename()
 {
     $this->assertTrue($this->filesystem->rename('1.txt', '3.txt'));
     $this->assertFalse($this->filesystem->has('1.txt'));
     $this->assertTrue($this->filesystem->has('3.txt'));
 }
开发者ID:apollopy,项目名称:flysystem-aliyun-oss,代码行数:10,代码来源:AliyunOssAdapterTest.php

示例14: rename

 /**
  * @param Payload $payload
  * @param Messenger $messenger
  * @return PromiseInterface
  */
 public function rename(Payload $payload, Messenger $messenger)
 {
     return \React\Promise\resolve(['renamed' => $this->flysystem->rename($payload['from'], $payload['to'])]);
 }
开发者ID:WyriHaximus,项目名称:reactphp-filesystem-flysystem,代码行数:9,代码来源:Worker.php

示例15: rename

 /**
  * @inheritdoc
  */
 public function rename($path, $newpath)
 {
     try {
         return parent::rename($path, $newpath);
     } catch (\Exception $e) {
         $this->errors[] = $e->getMessage();
     }
     return false;
 }
开发者ID:romeoz,项目名称:rock-file,代码行数:12,代码来源:FileManager.php


注:本文中的League\Flysystem\Filesystem::rename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。