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


PHP FileSystem::rename方法代码示例

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


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

示例1: storeFile

 /**
  * Store a file and return the hash
  * @param  File $file
  * @return string $hash
  */
 public function storeFile(File $file)
 {
     $hash = md5_file($file->getPathname());
     if (!$this->fileSystem->exists($this->getPath($hash))) {
         $this->fileSystem->rename($file->getPathname(), $this->getPath($hash));
     }
     return $hash;
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:13,代码来源:TemporaryFileSystem.php

示例2: storeLearningMaterialFile

 /**
  * Store a learning material file and return the relativePath
  * @param File $file
  * @param boolean $preserveOriginalFile
  * @return string $relativePath
  */
 public function storeLearningMaterialFile(File $file, $preserveOriginalFile = true)
 {
     $relativePath = $this->getLearningMaterialFilePath($file);
     $fullPath = $this->getPath($relativePath);
     $dir = dirname($fullPath);
     $this->fileSystem->mkdir($dir);
     if ($preserveOriginalFile) {
         $this->fileSystem->copy($file->getPathname(), $fullPath, false);
     } else {
         if (!$this->fileSystem->exists($fullPath)) {
             $this->fileSystem->rename($file->getPathname(), $fullPath);
         }
     }
     return $relativePath;
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:21,代码来源:IliosFileSystem.php

示例3: extractTo

 public function extractTo($extractPath, $files = null)
 {
     $fs = new FileSystem();
     $ds = DIRECTORY_SEPARATOR;
     for ($i = 0; $i < $this->numFiles; $i++) {
         $oldName = parent::getNameIndex($i);
         $newName = mb_convert_encoding($this->getNameIndex($i), 'ISO-8859-1', 'CP850,UTF-8');
         //we cheat a little because we can't tell wich name the extracted part should have
         //so we put it a directory wich share it's name
         $tmpDir = $extractPath . $ds . '__claro_zip_hack_' . $oldName;
         parent::extractTo($tmpDir, parent::getNameIndex($i));
         //now we move the content of the directory and we put the good name on it.
         foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
             if ($item->isFile()) {
                 $fs->mkdir(dirname($extractPath . $ds . $oldName));
                 $fs->rename($item->getPathname(), $extractPath . $ds . $oldName);
             }
         }
     }
     //we remove our 'trash here'
     $iterator = new \DirectoryIterator($extractPath);
     foreach ($iterator as $item) {
         if (strpos($item->getFilename(), '_claro_zip_hack')) {
             $fs->rmdir($item->getRealPath(), true);
         }
     }
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:27,代码来源:ZipArchive.php

示例4: renameFile

 /**
  * @param $file
  * @param $newName new filename
  * @return StandardResponseInterface
  */
 public function renameFile($file, $newName)
 {
     if (!$this->isNameValid($newName)) {
         return new StandardResponse(false, 'New name not valid');
     }
     $fullPath = $this->getRealPath($file);
     $this->fs->rename($fullPath, dirname($fullPath) . '/' . $newName);
     return new StandardResponse();
 }
开发者ID:tamcy,项目名称:ElendevRoxyFilemanBundle,代码行数:14,代码来源:LocalFileSystem.php

示例5: rename

 /**
  * Renames a file or directory
  */
 public function rename($path_from, $path_to)
 {
     if (!$this->initPath($path_to)) {
         return FALSE;
     }
     $keyTo = $this->getFileName();
     if (!$this->initPath($path_from)) {
         return FALSE;
     }
     $keyFrom = $this->getFileName();
     return $this->fileSystem->rename($keyFrom, $keyTo);
 }
开发者ID:sallyx,项目名称:redis-php-stream-wrapper,代码行数:15,代码来源:Wrapper.php

示例6: createBackup

 /**
  * create backup by renaming original file
  *
  * @param string $fileName		file name
  */
 function createBackup($fileName)
 {
     $ext = substr($fileName, strrpos($fileName, '.'));
     $name = substr($fileName, 0, strrpos($fileName, '.'));
     $backupName = $fileName;
     $cnt = 0;
     while ($this->getEntryByName($backupName)) {
         $cnt++;
         $backupName = $name . "({$cnt}){$ext}";
     }
     if ($cnt > 0) {
         $this->FileSystem->rename($this->curDir . '/' . $fileName, $this->curDir . '/' . $backupName);
     }
 }
开发者ID:andreyvit,项目名称:retester,代码行数:19,代码来源:Listing.php


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