/** * Open the stream. * * @return \Hoa\Stream * @throws \Hoa\Stream\Exception */ public final function open() { $context = $this->_context; if (true === $this->_hasBeenDiffered) { if (null === $context) { $handle = Context::getInstance(uniqid()); $handle->setParameters(['notification' => [$this, '_notify']]); $context = $handle->getId(); } elseif (true === Context::contextExists($context)) { $handle = Context::getInstance($context); $parameters = $handle->getParameters(); if (!isset($parameters['notification'])) { $handle->setParameters(['notification' => [$this, '_notify']]); } } } $this->_bucket = self::_getStream($this->_streamName, $this, $context); return $this; }
/** * Create a directory. * * @param string $name Directory name. * @param string $mode Create mode. Please, see the self::MODE_CREATE* * constants. * @param string $context Context ID (please, see the * \Hoa\Stream\Context class). * @return bool * @throws \Hoa\File\Exception */ public static function create($name, $mode = self::MODE_CREATE_RECURSIVE, $context = null) { if (true === is_dir($name)) { return true; } if (empty($name)) { return false; } if (null !== $context) { if (false === Stream\Context::contextExists($context)) { throw new Exception('Context %s was not previously declared, cannot retrieve ' . 'this context.', 2, $context); } else { $context = Stream\Context::getInstance($context); } } if (null === $context) { return @mkdir($name, 0755, self::MODE_CREATE_RECURSIVE === $mode); } return @mkdir($name, 0755, self::MODE_CREATE_RECURSIVE === $mode, $context->getContext()); }