本文整理汇总了PHP中League\Flysystem\FilesystemInterface::rename方法的典型用法代码示例。如果您正苦于以下问题:PHP FilesystemInterface::rename方法的具体用法?PHP FilesystemInterface::rename怎么用?PHP FilesystemInterface::rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\FilesystemInterface
的用法示例。
在下文中一共展示了FilesystemInterface::rename方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _move
/**
* Move file into another parent dir.
* Return new file path or false.
*
* @param string $source source file path
* @param string $target target dir path
* @param string $name file name
* @return string|bool
**/
protected function _move($source, $target, $name)
{
$path = $this->_joinPath($target, $name);
if ($this->fs->rename($source, $path)) {
return $path;
}
return false;
}
示例2: move
/**
* Move (rename) a file or directory.
*
* @param string $source
* @param string $destination
* @throws IoWriteException
*/
public function move($source, $destination)
{
try {
$this->fs->rename($source, $destination);
} catch (Error $ex) {
throw new IoWriteException("File {$source} could not be moved to {$destination}.", $ex);
} catch (Exception $ex) {
throw new IoWriteException("File {$source} could not be moved to {$destination}.", $ex);
}
}
示例3: migrateFile
/**
* Migrates a file to the new strategy if it's not present
*
* @internal
* @param $path
* @return void
*/
public function migrateFile($path)
{
if ($this->getAdapterType() !== 'local' || $this->isEncoded($path)) {
return;
}
$encodedPath = $this->strategy->encode($path);
if ($this->filesystem->has($path) && !$this->filesystem->has($encodedPath)) {
$this->filesystem->rename($path, $encodedPath);
}
}
示例4: extract
/** @inheritdoc */
public function extract($zipBallPath, $to)
{
$absolutePathToZipBall = $this->filesystem->getAdapter()->applyPathPrefix($zipBallPath);
if ($this->zip->open($absolutePathToZipBall) === true) {
$absolutePathToExtract = $this->filesystem->getAdapter()->applyPathPrefix($to);
$this->zip->extractTo($absolutePathToExtract);
$this->zip->close();
$zipCreatedFolder = Linq::from($this->filesystem->listContents($to))->single(function ($object) {
return $object['type'] == 'dir';
})['path'];
foreach ($this->filesystem->listContents($zipCreatedFolder, true) as $object) {
if ($object['type'] == "file") {
$segments = explode('/', $object['path']);
unset($segments[4]);
$this->filesystem->rename($object['path'], implode('/', $segments));
}
}
$this->filesystem->deleteDir($zipCreatedFolder);
return;
}
throw new ZipExtractionFailed($zipBall, $to);
}
示例5: move
/**
* @override
* @inheritDoc
*/
public function move($source, $destination)
{
$ex = null;
$status = false;
try {
$status = $this->fs->rename($source, $destination);
} catch (Error $ex) {
} catch (Exception $ex) {
}
if (!$status || $ex !== null) {
throw new WriteException("File {$source} could not be moved to {$destination}.", $ex);
}
}
示例6: renameFile
/**
* Renames a file in this storage.
*
* @param string $fileIdentifier
* @param string $newName The target path (including the file name!)
* @return string The identifier of the file after renaming
* @throws ExistingTargetFileNameException
*/
public function renameFile($fileIdentifier, $newName)
{
// Makes sure the Path given as parameter is valid
$newName = $this->sanitizeFileName($newName);
$newIdentifier = $this->canonicalizeAndCheckFileIdentifier($newName);
// The target should not exist already
if ($this->fileExists($newIdentifier)) {
throw new ExistingTargetFileNameException('The target file "' . $newIdentifier . '" already exists.', 1320291063);
}
$sourcePath = ltrim($fileIdentifier, '/');
$targetPath = ltrim($newIdentifier, '/');
$result = $this->filesystem->rename($sourcePath, $targetPath);
if ($result === false) {
throw new \RuntimeException('Renaming file ' . $sourcePath . ' to ' . $targetPath . ' failed.', 1320375115);
}
return $newIdentifier;
}
示例7: move
/**
* Move a file to a new location.
*
* @param string $from
* @param string $to
* @return bool
*/
public function move($from, $to)
{
return $this->driver->rename($from, $to);
}
示例8: _move
/**
* Move file into another parent dir.
* Return new file path or false.
*
* @param string $source source file path
* @param string $target target dir path
* @param string $name file name
* @return string|bool
**/
protected function _move($source, $target, $name)
{
$path = $this->_joinPath($target, $name);
return $this->_resultPath($this->fs->rename($source, $path), $path);
}
示例9: rename
/**
* Rename 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 rename($path, $newpath)
{
return $this->fileSystem->rename($path, $newpath);
}