Opens file or URL. This method is called immediately after the wrapper is initialized.

@see http://www.php.net/manual/en/streamwrapper.stream-open.php
164179
public function stream_open(string $url, string $mode, int $options, ?string &$openedPath): bool
    {
        $partition = self::getPartition($url);
        $path = self::getRelativePath($url);

        $this->filePointer = $partition->fileOpen(
            $path, $mode, $options
        );

        $result = (bool) $this->filePointer;
        if ($result && ($options & STREAM_USE_PATH)) {
            $openedPath = $path;
        }

        return $result;
    }
203545
protected function load()
    {
        $json = file_get_contents($this->filename);
        if (false === $json) {
            // @codeCoverageIgnoreStart
            throw new RuntimeException('Unable to open file ' . $this->filename);
            // @codeCoverageIgnoreEnd
        }

        $this->unserialize($json);
        $this->cookies = $this->cookies ?: array();
    }
914498
private void openStream() throws IOException {
    if (mIn != null) { // stream is already open
      return;
    }
    GetObjectRequest getReq = new GetObjectRequest(mBucketName, mKey);
    // If the position is 0, setting range is redundant and causes an error if the file is 0 length
    if (mPos > 0) {
      getReq.setRange(mPos);
    }
    AmazonS3Exception lastException = null;
    while (mRetryPolicy.attempt()) {
      try {
        mIn = mClient.getObject(getReq).getObjectContent();
        return;
      } catch (AmazonS3Exception e) {
        LOG.warn("Attempt {} to open key {} in bucket {} failed with exception : {}",
            mRetryPolicy.getAttemptCount(), mKey, mBucketName, e.toString());
        if (e.getStatusCode() != HttpStatus.SC_NOT_FOUND) {
          throw new IOException(e);
        }
        // Key does not exist
        lastException = e;
      }
    }
    // Failed after retrying key does not exist
    throw new IOException(lastException);
  }
1276897
public function start()
    {
        try {
            /* raw input handler */
            $raw = file_get_contents(php_sapi_name() === 'cli' ? 'php://stdin' : 'php://input');
            if ($this->rawInputHandler !== null) {
                call_user_func($this->rawInputHandler, $raw);
            }
            /* parse the incoming request */
            $request = new Request($raw);
            /* find the CallFlow */
            if (array_key_exists($request->app, $this->cf)) {
                $cf = $this->cf[$request->app];
            } elseif (array_key_exists('*', $this->cf)) {
                $cf = $this->cf['*'];
            } else {
                throw new \Exception("CallFlow for '{$request->app}' Not Found", 404);
            }
            /* call the previous callback. if response is null, we just received a HANGUP */
            if (($label = $cf->callback($request)) !== null) {
                /* call the next label */
                $response = $cf->execute($label);
                /* output response */
                echo $response->getJSON();
            }
        } catch (\Exception $e) {
            /* if an exception is thrown, we reply with an HTTP error */
            echo $this->httpError($e->getMessage(), $e->getCode());
        }
        $output = ob_get_contents();
        /* raw output handler */
        if ($this->rawOutputHandler !== null) {
            call_user_func($this->rawOutputHandler, $output);
        }
        /* Content-Type */
        header('Content-Type: '.self::CONTENT_TYPE);
        /* flush output buffer */
        ob_end_flush();
    }
548366
@Override
	public void open(Configuration parameters) throws Exception {
		try {
			client = new Socket(hostIp, port);
			outputStream = client.getOutputStream();
			streamWriter = new DataOutputViewStreamWrapper(outputStream);
		}
		catch (IOException e) {
			throw new IOException("Cannot connect to the client to send back the stream", e);
		}
	}
568269
protected void openFile() {

        try {
            FileAccess   fa  = isDump ? FileUtil.getDefaultInstance()
                                      : database.getFileAccess();
            OutputStream fos = fa.openOutputStreamElement(outFile);

            outDescriptor = fa.getFileSync(fos);
            fileStreamOut = new BufferedOutputStream(fos, 2 << 12);
        } catch (IOException e) {
            throw Error.error(ErrorCode.FILE_IO_ERROR,
                              ErrorCode.M_Message_Pair, new Object[] {
                e.toString(), outFile
            });
        }
    }
162400
function Open()
	{
		$this->Observe("DataAdapter ($this->_label) Opening Connection...",OBSERVE_DEBUG);
		
		if ($this->_dbopen)
		{
			$this->Observe("DataAdapter ($this->_label) Connection Already Open",OBSERVE_WARN);
		}
		else
		{
			if (!$this->_driver) $this->LoadDriver();
			
			try
			{
				$this->_dbconn = $this->_driver->Open(
					$this->ConnectionSetting->ConnectionString, 
					$this->ConnectionSetting->DBName, 
					$this->ConnectionSetting->Username, 
					$this->ConnectionSetting->Password,
					$this->ConnectionSetting->Charset,
					$this->ConnectionSetting->BootstrapSQL);
				
				$this->_num_retries = 0;
			}
			catch (Exception $ex)
			{
				// retry one time a communication error occurs
				if ($this->_num_retries == 0 && DataAdapter::$RETRY_ON_COMMUNICATION_ERROR && $this->IsCommunicationError($ex))
				{
					$this->_num_retries++;
					$this->Observe("DataAdapter ($this->_label) Communication error.  Retry attempt " . $this->_num_retries, OBSERVE_WARN);
					sleep(2); // slight delay to prevent throttling
					return $this->Open();
				}

				$msg = "DataAdapter ($this->_label) Error Opening DB: " . $ex->getMessage() . ' (retry attempts: '.$this->_num_retries.')';
					
				$this->Observe($msg,OBSERVE_FATAL);
				throw new Exception($msg,$ex->getCode());
			}
			
			$this->_dbopen = true;
			$this->Observe("DataAdapter ($this->_label) Connection Open",OBSERVE_DEBUG);
		}
	}
408353
public function open()
    {
        if (is_resource($this->stream)) {
            throw new ResourceException(
                'The temporary file is already open.'
            );
        }

        $this->stream = fopen($this->lock_filename, 'w+b');
    }
824793
public function open()
    {
        if ($logFile = $this->genLogFile(true)) {
            if ($this->fileHandle) {
                fclose($this->fileHandle);
            }

            $this->file = $logFile;
            $this->fileHandle = @fopen($logFile, 'ab');

            if (!$this->fileHandle) {
                $this->stderr("Could not open the log file {$logFile}");
            }
        }
    }
41392
private synchronized void openFile()
  {
    try
    {
      String fName = _directory.getAbsolutePath()
                     + File.separatorChar + StreamLoader.FILE_PREFIX
                     + _stamp + _fileCount;
      if (_loader._compressDataBeforePut)
      {
        fName += StreamLoader.FILE_SUFFIX;
      }
      LOGGER.debug("openFile: {}", fName);

      OutputStream fileStream = new FileOutputStream(fName);
      if (_loader._compressDataBeforePut)
      {
        OutputStream gzipOutputStream = new GZIPOutputStream(
            fileStream, 64 * 1024, true)
        {
          {
            def.setLevel((int) _loader._compressLevel);
          }
        };
        _outstream = new BufferedOutputStream(gzipOutputStream);
      }
      else
      {
        _outstream = new BufferedOutputStream(fileStream);
      }

      _file = new File(fName);

      _fileCount++;
    }
    catch (IOException ex)
    {
      _loader.abort(new Loader.ConnectionError(Utils.getCause(ex)));
    }
  }
1326397
public function stream_open(string $uri, string $mode, int $options, &$openedPath): bool
    {
        if (null === self::$server) {
            trigger_error(sprintf(
                'HTTP wrapper must be registered using %s::register() method',
                self::class
            ), E_USER_WARNING);

            return false;
        }

        if (in_array($mode, ['w', 'w+', 'a', 'a+', 'x', 'x+', 'c', 'c+'], true)) {
            trigger_error('HTTP wrapper does not support writeable connections', E_USER_WARNING);

            return false;
        }

        $protocolVersion = 1.0;
        $method = 'GET';
        $headers = [];
        $body = null;
        $userAgent = ini_get('user_agent');

        $followRedirects = true;
        $maxRedirects = 20;

        if (null !== $this->context) {
            $contextOptions = stream_context_get_options($this->context);
            $contextOptions = $contextOptions['http'] ?? [];

            if (isset($contextOptions['method'])) {
                $method = $contextOptions['method'];
            }

            if (isset($contextOptions['header'])) {
                foreach ((array) $contextOptions['header'] as $header) {
                    if (!is_string($header) || !strpos($header, ':')) {
                        continue;
                    }

                    list($name, $value) = preg_split('/:\s*/', $header, 2);
                    if (!isset($headers[$name])) {
                        $headers[$name] = $value;
                    }
                }
            }

            if (isset($contextOptions['user_agent'])) {
                $userAgent = $contextOptions['user_agent'];
            }

            if (isset($contextOptions['content'])) {
                $body = $contextOptions['content'];
            }

            if (isset($contextOptions['follow_location'])) {
                $followRedirects = (bool) $contextOptions['follow_location'];
            }

            if (isset($contextOptions['max_redirects'])) {
                $maxRedirects = (int) $contextOptions['max_redirects'];
            }

            if (isset($contextOptions['protocol_version'])) {
                $protocolVersion = (float) $contextOptions['protocol_version'];
            }
        }

        $protocolVersion = sprintf('%01.1f', $protocolVersion);

        if ('' !== $userAgent && !in_array('user-agent', array_map('strtolower', array_keys($headers)), true)) {
            $headers['User-Agent'] = $userAgent;
        }

        $request = new Request($method, $uri, $headers, $body, $protocolVersion);

        if (null === $this->response = self::$server->handle($request)) {
            return $this->triggerError(sprintf(
                'The server used by HTTP wrapper returned no response for request %s %s.',
                $request->getMethod(),
                $request->getUri()
            ), $options);
        }

        if ($this->response->getStatusCode() >= 400) {
            return $this->triggerError(sprintf(
                'Request %s %s failed: %d %d.',
                $request->getMethod(),
                $request->getUri(),
                $this->response->getStatusCode(),
                $this->response->getReasonPhrase()
            ), $options);
        }

        if ($followRedirects) {
            $redirections = 0;
            $currentRequest = $request;
            while (($redirectUri = $this->response->getHeader('Location')) && '' !== $redirectUri = $redirectUri[0]) {
                $requestUri = $currentRequest->getUri();

                if (false === strpos($redirectUri, '://')) {
                    if (0 !== strpos($redirectUri, '/')) {
                        $path = $requestUri->getPath();
                        $redirectUri = substr($path, 0, strrpos($path, '/') + 1).'/'.$redirectUri;
                    }

                    if (null !== $port = $requestUri->getPort()) {
                        $redirectUri = ':'.$port.$redirectUri;
                    }

                    $redirectUri = $requestUri->getScheme().'://'.$requestUri->getHost().$redirectUri;
                }

                if ($redirections++ >= $maxRedirects) {
                    return $this->triggerError(sprintf(
                        'Request %s %s got redirected to %s but redirection limit (%d) has been reached.',
                        $request->getMethod(),
                        $request->getUri(),
                        $redirectUri,
                        $maxRedirects
                    ), $options);
                }

                $currentRequest = new Request('GET', $redirectUri, $headers, null, $protocolVersion);

                if (null === $this->response = self::$server->handle($currentRequest)) {
                    return $this->triggerError(sprintf(
                        'Request %s %s got redirected to %s but no response was returned by the server.',
                        $request->getMethod(),
                        $request->getUri(),
                        $redirectUri
                    ), $options);
                }

                if ($this->response->getStatusCode() >= 400) {
                    return $this->triggerError(sprintf(
                        'Request %s %s failed: %d %d.',
                        $request->getMethod(),
                        $request->getUri(),
                        $this->response->getStatusCode(),
                        $this->response->getReasonPhrase()
                    ), $options);
                }
            }
        }

        $body = $this->response->getBody();
        if ($body->isSeekable()) {
            $body->rewind();
        }

        return true;
    }
904591
public function stream_open($uri, $mode, $options, &$opened_path)
    {
        $this->uri = $uri;
        $path = $this->getTarget();

        $this->isReadOnly = StreamUtil::modeIsReadOnly($mode);
        $this->isWriteOnly = StreamUtil::modeIsWriteOnly($mode);
        $this->isAppendMode = StreamUtil::modeIsAppendable($mode);

        $this->handle = $this->invoke($this, 'getStream', [$path, $mode], 'fopen');

        if ($this->handle && $options & STREAM_USE_PATH) {
            $opened_path = $path;
        }

        return is_resource($this->handle);
    }
158619
public function stream_open($path, $mode, $options, &$opened_path)
    {
        if ($this->fileHandle !== null) {
            return false;
        }
        self::restore();
        $path = self::overlayPath($path);
        $this->fileHandle = fopen($path, $mode, (bool)($options & STREAM_USE_PATH));
        self::register();
        return $this->fileHandle !== false;
    }
543317
@Override
    public InputStream openInputStream() throws IOException {
        if (outputStream != null) {
            return new ByteArrayInputStream(outputStream.toByteArray());
        } else {
            return new ByteArrayInputStream(new byte[0]);
        }
    }
234804
private void openStream() throws IOException {
    if (mClosed) {
      throw new IOException("Stream closed");
    }
    if (mMultiRangeChunkSize <= 0) {
      throw new IOException(ExceptionMessage.BLOCK_SIZE_INVALID.getMessage(mMultiRangeChunkSize));
    }

    if (mStream != null) { // stream is already open
      return;
    }
    final long endPos = mPos + mMultiRangeChunkSize - (mPos % mMultiRangeChunkSize);
    mEndPos = endPos;
    mStream = createStream(mPos, endPos);
  }
1132786
public function open()
    {
        if ($this->isOpen() === true) {
            $msg = "The MemoryStream is already open.";
            throw new MemoryStreamException($msg, $this, MemoryStreamException::ALREADY_OPEN);
        }

        $this->setOpen(true);
    }
1061041
public function stream_open(string $uri, string $mode, int $options, &$openedPath): bool
    {
        list($protocol, $path) = $this->parseUri($uri);

        $this->meta = $this->checkResource($path);


        $path = $this->meta->getRealPath();

        /** @noinspection ReturnFalseInspection */
        $this->body = $this->decorate($protocol, \file_get_contents($path), $path);

        return true;
    }