public function vfsStreamWrapper::rename in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php \org\bovigo\vfs\vfsStreamWrapper::rename()
rename from one path to another
@author Benoit Aubuchon
Parameters
string $path_from:
string $path_to:
Return value
bool
1 call to vfsStreamWrapper::rename()
- vfsStreamWrapperRecordingProxy::rename in vendor/
mikey179/ vfsStream/ src/ test/ php/ org/ bovigo/ vfs/ proxy/ vfsStreamWrapperRecordingProxy.php - rename from one path to another
1 method overrides vfsStreamWrapper::rename()
- vfsStreamWrapperRecordingProxy::rename in vendor/
mikey179/ vfsStream/ src/ test/ php/ org/ bovigo/ vfs/ proxy/ vfsStreamWrapperRecordingProxy.php - rename from one path to another
File
- vendor/
mikey179/ vfsStream/ src/ main/ php/ org/ bovigo/ vfs/ vfsStreamWrapper.php, line 787
Class
- vfsStreamWrapper
- Stream wrapper to mock file system requests.
Namespace
org\bovigo\vfsCode
public function rename($path_from, $path_to) {
$srcRealPath = $this
->resolvePath(vfsStream::path($path_from));
$dstRealPath = $this
->resolvePath(vfsStream::path($path_to));
$srcContent = $this
->getContent($srcRealPath);
if (null == $srcContent) {
trigger_error(' No such file or directory', E_USER_WARNING);
return false;
}
$dstNames = $this
->splitPath($dstRealPath);
$dstParentContent = $this
->getContent($dstNames['dirname']);
if (null == $dstParentContent) {
trigger_error('No such file or directory', E_USER_WARNING);
return false;
}
if (!$dstParentContent
->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
trigger_error('Permission denied', E_USER_WARNING);
return false;
}
if ($dstParentContent
->getType() !== vfsStreamContent::TYPE_DIR) {
trigger_error('Target is not a directory', E_USER_WARNING);
return false;
}
// remove old source first, so we can rename later
// (renaming first would lead to not being able to remove the old path)
if (!$this
->doUnlink($srcRealPath)) {
return false;
}
$dstContent = $srcContent;
// Renaming the filename
$dstContent
->rename($dstNames['basename']);
// Copying to the destination
$dstParentContent
->addChild($dstContent);
return true;
}