Set the fopen mode.

@param string $mode
The mode string, e.g. `r+` or `wb`.

@retval HPCloud::Storage::ObjectStorage::StreamWrapper
@return \HPCloud\Storage\ObjectStorage\StreamWrapper
$this so the method can be used in chaining.
193395
protected function setMode($mode) {
    $mode = strtolower($mode);

    // These are largely ignored, as the remote
    // object storage does not distinguish between
    // text and binary files. Per the PHP recommendation
    // files are treated as binary.
    $this->isBinary = strpos($mode, 'b') !== FALSE;
    $this->isText = strpos($mode, 't') !== FALSE;

    // Rewrite mode to remove b or t:
    $mode = preg_replace('/[bt]?/', '', $mode);

    switch ($mode) {
      case 'r+':
        $this->isWriting = TRUE;
      case 'r':
        $this->isReading = TRUE;
        $this->createIfNotFound = FALSE;
        break;


      case 'w+':
        $this->isReading = TRUE;
      case 'w':
        $this->isTruncating = TRUE;
        $this->isWriting = TRUE;
        break;


      case 'a+':
        $this->isReading = TRUE;
      case 'a':
        $this->isAppending = TRUE;
        $this->isWriting = TRUE;
        break;


      case 'x+':
        $this->isReading = TRUE;
      case 'x':
        $this->isWriting = TRUE;
        $this->noOverwrite = TRUE;
        break;

      case 'c+':
        $this->isReading = TRUE;
      case 'c':
        $this->isWriting = TRUE;
        break;

      // nope mode: Mock read/write support,
      // but never write to the remote server.
      // (This is accomplished by never marking
      // the stream as dirty.)
      case 'nope':
        $this->isReading = TRUE;
        $this->isWriting = TRUE;
        $this->isNeverDirty = TRUE;
        break;

      // Default case is read/write
      // like c+.
      default:
        $this->isReading = TRUE;
        $this->isWriting = TRUE;
        break;

    }

    return $this;
  }
691093
public Ftp setMode(FtpMode mode) {
		this.mode = mode;
		switch (mode) {
		case Active:
			this.client.enterLocalActiveMode();
			break;
		case Passive:
			this.client.enterLocalPassiveMode();
			break;
		}
		return this;
	}
1148226
public function setMatchMode($mode)
    {
        assert($mode == SPH_MATCH_ALL
            || $mode == SPH_MATCH_ANY
            || $mode == SPH_MATCH_PHRASE
            || $mode == SPH_MATCH_BOOLEAN
            || $mode == SPH_MATCH_EXTENDED
            || $mode == SPH_MATCH_FULLSCAN
            || $mode == SPH_MATCH_EXTENDED2);
        $this->_mode = $mode;

        return $this;
    }
716480
public function mode($mode = null)
    {
        if (func_num_args() === 0) {
            return $this->_mode;
        }
        $this->_mode = $mode;
        return $this;
    }
248906
public function setRequestMode($mode)
    {
        if (!in_array($mode, ['real', 'simu'])) {
            $message = sprintf(
              'The request mode %s is not supported, real or simu expected!',
              $mode
            );
            throw new \InvalidArgumentException($message, 500);
        }
        $this->params['request_mode'] = $mode;
        return $this;
    }
1347332
public function setMode($mode)
    {
        $availableModes = $this->availableModes();
        if (!in_array($mode, $availableModes)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid ID mode. Must be one of "%s"',
                implode(', ', $availableModes)
            ));
        }

        $this->mode = $mode;

        return $this;
    }
1178282
public function open(string $mode)
    {
        $read = strpbrk($mode, "r+") !== false;
        $write = strpbrk($mode, "waxc+") !== false;
        $x = strpbrk($mode, "x") !== false;

        $path = $this->getFullPath();
        $fh = @fopen($path, $mode);
        if (is_resource($fh))
            return $fh;

        if ($x && file_exists($path))
            throw new IOException("File already exists: " . $path);
        if ($write && !is_writable($path))
            throw new IOException("File is not writable: " . $path);
        if ($read && !is_readable($path))
            throw new IOException("File is not readable: " . $path);

        throw new IOException("Invalid mode for opening file: " . $mode);
    }
1302458
protected function _mode($mode)
	{
		if ($mode == FTP_BINARY)
		{
			if (!$this->_putCmd('TYPE I', 200))
			{
				throw new FilesystemException(
					sprintf('%1$s: Bad response. Server response: %2$s [Expected: 200]. Mode sent: Binary', __METHOD__, $this->response)
				);
			}
		}
		else
		{
			if (!$this->_putCmd('TYPE A', 200))
			{
				throw new FilesystemException(
					sprintf('%1$s: Bad response. Server response: %2$s [Expected: 200]. Mode sent: ASCII', __METHOD__, $this->response)
				);
			}
		}

		return true;
	}
866109
protected function _open($mode)
    {
        $this->_fileHandler = @fopen($this->_filePath, $mode);

        if (false === $this->_fileHandler) {
            throw new Mage_Exception('Failed to open file ' . $this->_filePath);
        }
    }
356781
public function open($file, $mode)
    {
        if (!empty(trim($file)) && !empty(trim($mode))) {
            $this->resource = fopen($file, $this->modes[$mode]);
            $this->file = $file;

            return $this;
        }

        return false;
    }
701360
public function begin($mode = IExpressionGroup::MODE_AND)
    {
        $parentGroup = $this->currentExpressionGroup;

        $group = $this->queryBuilderFactory->createExpressionGroup($mode, $parentGroup);
        if ($parentGroup) {
            $parentGroup->addGroup($group);
        }

        $this->currentExpressionGroup = $group;

        return $this;
    }
733349
public function setMode($mode)
    {
        if (!in_array($mode, [
            GetOpt::NO_ARGUMENT,
            GetOpt::OPTIONAL_ARGUMENT,
            GetOpt::REQUIRED_ARGUMENT,
            GetOpt::MULTIPLE_ARGUMENT,
        ], true)) {
            throw new \InvalidArgumentException(sprintf(
                'Option mode must be one of %s, %s, %s and %s',
                'GetOpt::NO_ARGUMENT',
                'GetOpt::OPTIONAL_ARGUMENT',
                'GetOpt::REQUIRED_ARGUMENT',
                'GetOpt::MULTIPLE_ARGUMENT'
            ));
        }
        $this->mode = $mode;
        return $this;
    }
941369
public function setFetchMode($mode)
    {
        switch ($mode) {
            case Zend_Db::FETCH_NUM:   // seq array
            case Zend_Db::FETCH_ASSOC: // assoc array
            case Zend_Db::FETCH_BOTH:  // seq+assoc array
            case Zend_Db::FETCH_OBJ:   // object
                $this->_fetchMode = $mode;
                break;
            case Zend_Db::FETCH_BOUND:   // bound to PHP variable
                /**
                 * @see Zend_Db_Adapter_Db2_Exception
                 */
                // require_once 'Zend/Db/Adapter/Db2/Exception.php';
                throw new Zend_Db_Adapter_Db2_Exception('FETCH_BOUND is not supported yet');
                break;
            default:
                /**
                 * @see Zend_Db_Adapter_Db2_Exception
                 */
                // require_once 'Zend/Db/Adapter/Db2/Exception.php';
                throw new Zend_Db_Adapter_Db2_Exception("Invalid fetch mode '$mode' specified");
                break;
        }
    }
702969
public function open($mode="c") {
		$this->mode = $mode;
		$this->file = fopen($this->filepath, $mode);
		if($this->file === false) {
			$this->mode = null;
			$this->file = null;
			$this->open = false;
			throw new \Exception("Unable to open file {$this->filepath}");
		}
		$this->open = true;
		return true;
	}
424163
public function setMapPermission($mode = null)
    {
        $this->permissionError = array();
        $this->permissionErrorRules = array();

        $params = $this->getParams();

        $permissionRules = $this->permissionRules;
        if (isset($mode)) {
            foreach ($permissionRules as &$value) {
                $value = $mode;
            }
        }

        $result = true;
        foreach ($params['permissionMap'] as $type => $items) {

            $permission = $permissionRules[$type];

            foreach ($items as $item) {

                if (file_exists($item)) {

                    try {
                        $this->chmod($item, $permission, true);
                    } catch (\Exception $e) {
                    }

                    $res = is_readable($item);

                    /** check is wtitable */
                    if ($type == 'writable') {

                        $res &= is_writable($item);

                        if (is_dir($item)) {
                            $name = uniqid();

                            try {
                                $res &= $this->getFileManager()->putContents(array($item, $name), 'test');
                                $res &= $this->getFileManager()->removeFile($name, $item);
                            } catch (\Exception $e) {
                                $res = false;
                            }
                        }
                    }

                    if (!$res) {
                        $result = false;
                        $this->permissionError[] = $item;
                        $this->permissionErrorRules[$item] = $permission;
                    }
                }
            }
        }

        return $result;
    }
1358864
private function setStream($stream, $mode = 'r')
    {
        $error    = null;
        $resource = $stream;

        if (is_string($stream)) {
            set_error_handler(function ($e) use (&$error) {
                $error = $e;
            }, E_WARNING);
            $resource = fopen($stream, $mode);
            restore_error_handler();
        }

        if ($error) {
            throw new InvalidArgumentException('Invalid stream reference provided');
        }

        if (! is_resource($resource) || 'stream' !== get_resource_type($resource)) {
            throw new InvalidArgumentException(
                'Invalid stream provided; must be a string stream identifier or stream resource'
            );
        }

        if ($stream !== $resource) {
            $this->stream = $stream;
        }

        $this->resource = $resource;
    }
314304
public function setDefaultMode(string $mode = null) : RauthInterface
    {
        if (!in_array($mode, self::MODES)) {
            throw new \InvalidArgumentException(
                'Mode ' . $mode . ' not accepted!'
            );
        }
        $this->defaultMode = $mode;

        return $this;
    }