/** * constructor * * @param string $name * @param int $permissions optional */ public function __construct($name, $permissions = null) { $this->type = vfsStreamContent::TYPE_FILE; parent::__construct($name, $permissions); }
/** * sets parent path * * @param string $parentPath * @internal only to be set by parent * @since 1.2.0 */ public function setParentPath($parentPath) { parent::setParentPath($parentPath); foreach ($this->children as $child) { $child->setParentPath($this->path()); } }
/** * renames the content * * @param string $newName * @throws vfsStreamException */ public function rename($newName) { if (strstr($newName, '/') !== false) { throw new vfsStreamException('Directory name can not contain /.'); } parent::rename($newName); }
/** * executes given permission change when necessary rights allow such a change * * @param string $path * @param vfsStreamAbstractContent $content * @param \Closure $change * @return bool */ private function doPermChange($path, vfsStreamAbstractContent $content, \Closure $change) { if (!$content->isOwnedByUser(vfsStream::getCurrentUser())) { return false; } if (self::$root->getName() !== $path) { $names = $this->splitPath($path); $parent = $this->getContent($names['dirname']); if (!$parent->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) { return false; } } $change(); return true; }