Opens the current file with a given $mode

@param string $mode A valid 'fopen' mode string (r|w|a ...)
@param bool $force If true then the file will be re-opened even if its already opened, otherwise it won't
@return bool True on success, false on failure
183893
public function open($mode = 'r', $force = false)
    {
        if (!$force && is_resource($this->handle)) {
            return true;
        }
        if ($this->exists() === false && $this->create() === false) {
            return false;
        }

        $this->handle = fopen($this->path, $mode);

        return is_resource($this->handle);
    }
338974
private function fopen($force = false) {
            if ($force || !$this->fp) {
                $this->fclose();
                $this->fp = is_resource($this->config->savePath) ? $this->config->savePath
                    : fopen($this->config->savePath, 'ab');
            }

            return $this;
        }
824163
public function lock($mode = true)
    {
        $this->shouldLock = $mode;

        if (!$handle = $this->resource()) {
            return false;
        }

        return $this->applyLock($handle);

    }
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;
	}
271308
protected function openFile(string $file, string $mode)
    {
        $fp = @fopen($file, $mode);
        if (false === $fp) {
            throw new StreamException(
                    'Can not open file ' . $file . ' with mode ' . $mode . ': '
                    .
                    str_replace('fopen(' . $file . '): ', '', lastErrorMessage())
            );
        }

        return $fp;
    }
1171016
protected function _fopen($path, $mode='rb')
    {
        $fp = $this->tmbPath
            ? @fopen($this->tmpname($path), 'w+')
            : @tmpfile();

        if ($fp) {
            if (($res = $this->query('SELECT content FROM '.$this->tbf.' WHERE id="'.$path.'"'))
            && ($r = $res->fetch_assoc())) {
                fwrite($fp, $r['content']);
                rewind($fp);

                return $fp;
            } else {
                $this->_fclose($fp, $path);
            }
        }

        return false;
    }
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);
    }
250213
public function open($filename, $force = false)
    {
        if (!$this->filesystem->exists($filename) && $force) {
            return $this->filesystem->create($filename);
        }

        return $this->filesystem->open($filename);
    }
601609
public static function open($uri, $mode)
    {
        $fp = fopen($uri, $mode);
        
        if (!$fp) {
            throw new \RuntimeException("Failed to open the '$uri' stream in '$mode' mode");
        }
        
        return new static($fp);
    }
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;
    }
106220
protected function fopenCE($path, $mode='rb') {
		return (!$this->encoding)? $this->_fopen($path, $mode) : $this->convEncOut($this->_fopen($this->convEncIn($path), $mode));
	}
1177484
public static function createFile($file, $mode = 0775)
    {
        if (empty($file)) return false;
        if (is_file($file)) {
            return true;
        }
        $dir = dirname($file);
        self::createDir($dir);
        $fh = @fopen($file, 'a');
        if ($fh) {
            fclose($fh);
            return true;
        }
        return false;
    }
64874
public function set(string $mode): bool {
    $auth = false;
    file_exists($mode);
    switch ($mode) {
      case Debug::HOMOLOGATION:
      case Debug::DEVELOPER:
        ini_set('display_errors', true);
        error_reporting(E_ALL);
        $auth = true;
        break;
      case Debug::PRODUCTION:
        $auth = true;
      default:
        ini_set('display_errors', false);
        error_reporting(E_ERROR);
        $auth = $auth ?? false;
        break;
    }
    return $auth;
  }
1052643
protected function openAndLock($file, $mode, $operation)
    {
        if (!$handle = fopen($file, $mode)) {
            return false;
        }
        if (!flock($handle, $operation)) {
            fclose($handle);
            return false;
        }
        return $handle;
    }
1315585
public function createDirectory(&$f, $mode = 0755)
    {
        $old_umask = umask(0);
        $return = @mkdir($f->getAbsolutePath(), $mode);
        umask($old_umask);

        return $return;
    }
1310610
public static function is($mode){
       
        if(is_int($mode) && self::get() == $mode){
             
            return true;
        }
        if(is_string($mode) && self::get() == self::getModeByName($mode)){
            return true;
        }
        return false;
    }
241569
public function setTransferMode( $mode )
	{
		if( $mode != FTP_BINARY && $mode != FTP_ASCII )
			return FALSE;
		$this->mode	= $mode;
		return TRUE;
	}