Open stream

@param string $path
@param string $mode
@param mixed $options
@param mixed $opened_path
@return bool
499678
public function stream_open( $path, $mode, $options, &$opened_path )
    {
        $this->string   = substr( $path, strpos( $path, '//' ) + 2 );
        $this->position = 0;
        $this->length   = strlen( $this->string );

        return 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;
    }
777284
public static function open($path, $flags, $cb, $mode = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!FileSystem::$supported) {
            $mode = File::convertFlags($flags, true);
            $fd = fopen($path, $mode);
            if (!$fd) {
                $cb(false);
                return false;
            }
            $file = new File($fd, $path);
            $cb($file);
            return true;
        }
        $fdCacheKey = $path . "\x00" . $flags;
        $noncache = mb_orig_strpos($flags, '!') !== false;
        $flags = File::convertFlags($flags);
        if (!$noncache && ($item = FileSystem::$fdCache->get($fdCacheKey))) { // cache hit
            $file = $item->getValue();
            if ($file === null) { // operation in progress
                $item->addListener($cb);
            } else { // hit
                $cb($file);
            }
            return null;
        } elseif (!$noncache) {
            $item = FileSystem::$fdCache->put($fdCacheKey, null);
            $item->addListener($cb);
        }
        return eio_open($path, $flags, $mode, $pri, function ($path, $fd) use ($cb, $flags, $fdCacheKey, $noncache) {
            if ($fd === -1) {
                if ($noncache) {
                    $cb(false);
                } else {
                    FileSystem::$fdCache->put($fdCacheKey, false, self::$badFDttl);
                }
                return;
            }
            $file = new File($fd, $path);
            $file->append = ($flags | EIO_O_APPEND) === $flags;
            if ($file->append) {
                $file->stat(function ($file, $stat) use ($cb, $noncache, $fdCacheKey) {
                    $file->offset = $stat['size'];
                    if (!$noncache) {
                        $file->fdCacheKey = $fdCacheKey;
                        FileSystem::$fdCache->put($fdCacheKey, $file);
                    } else {
                        $cb($file);
                    }
                });
            } else {
                if (!$noncache) {
                    $file->fdCacheKey = $fdCacheKey;
                    FileSystem::$fdCache->put($fdCacheKey, $file);
                } else {
                    $cb($file);
                }
            }
        }, $path);
    }
147802
public function stream_open($path, $mode, $options, &$opened_path)
    {
        $name = $this->_getNamePart($path);
        // If we open the file for writing, just return true. Create the object
        // on fflush call
        if (strpbrk($mode, 'wax')) {
            $this->_objectName = $name;
            $this->_objectBuffer = null;
            $this->_objectSize = 0;
            $this->_position = 0;
            $this->_writeBuffer = true;
            $this->_getOssClient($path);

            return true;
        } else {
            // Otherwise, just see if the file exists or not
            try {
                $info = $this->_getOssClient($path)->getObjectMeta(AliyunOSS::getBucket(), $name);
                if ($info) {
                    $this->_objectName = $name;
                    $this->_objectBuffer = null;
                    $this->_objectSize = (int) $info['content-length'];
                    $this->_position = 0;
                    $this->_writeBuffer = false;

                    return true;
                }
            } catch (\OSS\Core\OssException $e) {
                return false;
            }
        }

        return false;
    }
305288
protected function _fopen($path, $mode='rb') {

		if (($mode == 'rb' || $mode == 'r')) {
			try {
				$res = $this->dropbox->media($path);
				$url = parse_url($res['url']);
 				$fp = stream_socket_client('ssl://'.$url['host'].':443');
 				fputs($fp, "GET {$url['path']} HTTP/1.0\r\n");
 				fputs($fp, "Host: {$url['host']}\r\n");
 				fputs($fp, "\r\n");
 				while(trim(fgets($fp)) !== ''){};
 				return $fp;
			} catch (Dropbox_Exception $e) {
				return false;
			}
		}
		
		if ($this->tmp) {
			$contents = $this->_getContents($path);
			
			if ($contents === false) {
				return false;
			}
			
			if ($local = $this->getTempFile($path)) {
				if (file_put_contents($local, $contents, LOCK_EX) !== false) {
					return @fopen($local, $mode);
				}
			}
		}

		return false;
	}
1036114
public function mkdir($path, $mode, $options) {
		$parts = explode('://', $path, 2);

		$this->scheme	= $parts[0];
		$this->id		= rtrim($parts[1], '/') . '/';
		$this->db		= self::$config[$this->scheme]['db'];
		$this->table	= self::$config[$this->scheme]['table'];

		$this->entry = [
			'id'	=> $this->id,
			'type'	=> 'dir',
			'data'	=> '',
			'ctime'	=> date('Y-m-d H:i:s', time()),
			'mtime'	=> date('Y-m-d H:i:s', time()),
		];

		//$this->db->insert($this->table, $this->entry);
		return false;
	}
1370200
public function stream_open($path, $mode, $options, &$opened_path)
	{
		$this->path = $path;
		$this->resource = fopen($this->getLocalFilesystemPath($path), $mode);
		
		return is_resource($this->resource);
	}
288456
public function dir_opendir($path, $options)
    {
        $dirName = $this->_getNamePart($path).'/';
        if (preg_match('@^([a-z0-9+.]|-)+://$@', $path) || $dirName == '/') {
            $list = $this->_getOssClient($path)->listObjects(AliyunOSS::getBucket());
        } else {
            $list = $this
                ->_getOssClient($path)
                ->listObjects(AliyunOSS::getBucket(), [
                    OssClient::OSS_PREFIX => $dirName,
                ]);
        }

        foreach ((array) $list->getPrefixList() as $l) {
            array_push($this->_bucketList, basename($l->getPrefix()));
        }

        foreach ((array) $list->getObjectList() as $l) {
            if ($l->getKey() == $dirName) {
                continue;
            }

            array_push($this->_bucketList, basename($l->getKey()));
        }

        return $this->_bucketList !== false;
    }
758910
def open(self, path, mode='r', *args, **kwargs):
        """"""
        return open(os.path.join(os.path.dirname(self.path), path),
                    mode=mode, *args, **kwargs)
348344
public function chmod($mode, $path)
    {
        $writeBinn = new BinnList;

        $writeBinn->addUint8(self::FSERV_CHMOD);
        $writeBinn->addStr($path);
        $writeBinn->addUint16($mode);

        $read = $this->writeAndReadSocket($writeBinn->serialize());

        $readBinn = new BinnList;
        $readBinn->binnOpen($read);
        $results = $readBinn->unserialize();

        if ($results[0] != self::FSERV_STATUS_OK) {
            throw new RuntimeException('Couldn\'t chmod: ' . isset($results[1]) ? $results[1] : 'Unknown');
        }

        return true;
    }
1099543
def reopen_io(io, path, mode = nil)
      begin
        if mode
          io.reopen(path, mode)
        else
          io.reopen(path)
        end
        io.binmode
      rescue ::Exception
      end
    end
116831
function Open($fpath, $mode = 'r')
	{
		// open the file
		$this->Close();

		$newdb = false;
		if ($mode == 'w')
		{
			// write & read only
			if (!($fd = @fopen($fpath, 'rb+')))
			{
				if (!($fd = @fopen($fpath, 'wb+')))
				{
					trigger_error("XDB::Open(" . basename($fpath) . ",w) failed.", E_USER_WARNING);
					return false;
				}
				// create the header
				$this->_write_header($fd);

				// 32 = header, 8 = Pointer
				$this->fsize = 32 + 8 * $this->hash_prime;	
				$newdb = true;
			}
		}
		else
		{
			// read only
			if (!($fd = @fopen($fpath, 'rb')))
			{
				trigger_error("XDB::Open(" . basename($fpath) . ",r) failed.", E_USER_WARNING);
				return false;
			}
		}

		// check the header
		if (!$newdb && !$this->_check_header($fd))
		{
			trigger_error("XDB::Open(" . basename($fpath) . "), invalid xdb format.", E_USER_WARNING);
			fclose($fd);
			return false;
		}

		// set the variable
		$this->fd = $fd;
		$this->mode = $mode;
		$this->Reset();

		// lock the file description until close
		if ($mode == 'w')
			flock($this->fd, LOCK_EX);

		return true;
	}
652309
public function createFromPath($path, $open_mode = 'r+')
    {
        $class = $this->writerClass;

        return $this->prepare($class::createFromPath($path, $open_mode));
    }
106220
protected function fopenCE($path, $mode='rb') {
		return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
	}
569875
private function createFile(string $path, string $mode = null, int $options = null)
    {
        $names = $this->splitPath($path);
        if (empty($names['dirname']) === true) {
            if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
                trigger_error('File ' . $names['basename'] . ' does not exist', E_USER_WARNING);
            }

            return false;
        }

        /** @var vfsStreamDirectory|null $dir */
        $dir = $this->getContentOfType($names['dirname'], vfsStreamContent::TYPE_DIR);
        if (null === $dir) {
            if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
                trigger_error('Directory ' . $names['dirname'] . ' does not exist', E_USER_WARNING);
            }

            return false;
        } elseif ($dir->hasChild($names['basename']) === true) {
            if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
                trigger_error('Directory ' . $names['dirname'] . ' already contains a director named ' . $names['basename'], E_USER_WARNING);
            }

            return false;
        }

        if (self::READ === $mode) {
            if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
                trigger_error('Can not open non-existing file ' . $path . ' for reading', E_USER_WARNING);
            }

            return false;
        }

        if ($dir->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
            if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
                trigger_error('Can not create new file in non-writable path ' . $names['dirname'], E_USER_WARNING);
            }

            return false;
        }

        /** @var vfsStreamFile $file */
        $file = vfsStream::newFile($names['basename'])->at($dir);

        return $file;
    }
1102805
public function stream_open($url, $mode, $options, &$openedPath)
  {
    $partition = self::getPartition($url);
    $path = self::getRelativePath($url);

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

    $result = !!$this->_filePointer;
    if ($result && ($options & STREAM_USE_PATH)) {
      $openedPath = $path;
    }
    return $result;
  }
569308
protected function upload($path, $contents, $mode)
    {
        $path = $this->applyPathPrefix($path);

        try {
            $object = $this->client->upload($path, $contents, $mode);

            return $this->normalizeResponse($object);
        } catch (\Exception $e) {
            return false;
        }
    }