Open the file.

@param (string) $file Name of file with oath.
@param (string) $mode Mode of file.

@since 3.0.0

@return resource
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;
    }
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;
	}
362365
private function load($file)
    {
        if (null === $this->command) {
            $this->command = Yaml::parse($file);
        }
        return $this->command;
    }
557628
protected function openJpeg($file)
    {
        if (file_exists($file) && filesize($file)) {
            $this->resource = @imagecreatefromjpeg($file);
        } else {
            $this->resource = false;
        }
    }
816954
protected function openFileHandle($mode = 'w+') {

        if($this->fileHandle !== null) {

            throw new TempFileException();
        }

        if(!($fileHandle = fopen($this->filePath, $mode))) {

            throw new TempFileException('Could not open file handle to temporary file.');
        }

        $this->fileHandle = $fileHandle;
    }
553830
public function makeFile($mode = FileSystemPermission::NORMAL)
    {
        $file = $this->factory->makeFile($mode);
        $this->container->add($file);

        return $file;
    }
817512
public function chmod($mode, $file) {
		$this->connectIfNeeded();
		$this->handle->chmod($mode, $file);
		$this->onFileModeChanged(
			new Event(['sender' => $this, 'data' => [
				'mode' => $mode, 'file' => $file
			]])
		);
	}
1169363
public function load($file)
	{
		$handle = strcasecmp(substr($file, -3), '.gz') ? fopen($file, 'rb') : gzopen($file, 'rb');
		if (!$handle) {
			throw new Exception("ERROR: Cannot open file '$file'.");
		}
		return $this->read($handle);
	}
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);
    }
1321213
public function sendFile($file) {
		if ($this->sent) {
			return $this;
		}

		$this->setMode(self::MODE_FILE);
		$this->send($file);

		return $this;
	}
835538
public function handle($file)
    {
        if (!$mime = $this->getMimeForEmit($file->getExtension())) {
            return $file;
        }
        if (!$file_loc = $file->getLocation()) {
            return $file;
        }
        $file->setMime($mime);
        $file->setFound();
        $fp   = fopen($file_loc, 'r');
        $file->setResource($fp);

        return $file;
    }
332233
public static function loadFile($file, $format = null)
    {
        if (!isset($format)) {
            $ext = pathinfo($file, PATHINFO_EXTENSION);
            $format = ArrayHelper::fetch(self::$FORMATS, $ext);
            if (!isset($format)) {
                throw new \InvalidArgumentException("Cannot infer format from file '{$file}'");
            }
        }
        if ($format == 'json') {
            return json_decode(file_get_contents($file), true);
        } elseif ($format == 'yaml') {
            return Yaml::parse(file_get_contents($file));
        } elseif ($format == 'php') {
            return require($file);
        } else {
            throw new \InvalidArgumentException("Invalid format '{$format}'");
        }
    }
800818
public function createFromFile($file, $mode = DATA_MANIPULATION_CREATE_MODE_AUTO, $extension = null)
    {
        $manipulator = new Manipulator();
        $manipulator->setFileInput($file, $mode, $extension);
        return $manipulator;
    }
702322
public function open($mode = 'a') {
        if (is_resource($this->stream)) {
            return $this;
        }
        $this->stream = fopen($this->file->getFullName(), $mode);
        return $this;
    }
1047782
public function load($file,$context)
	{
		if(!($fr=@fopen($file,'rb')))
			throw new CException(Yii::t('yii','Unable to read file "{file}".',
				array('{file}'=>$file)));

		if(!@flock($fr,LOCK_SH))
			throw new CException(Yii::t('yii','Unable to lock file "{file}" for reading.',
				array('{file}'=>$file)));

		$array=unpack('c',$this->readByte($fr,4));
		$magic=current($array);
		if($magic==-34)
			$this->useBigEndian=false;
		elseif($magic==-107)
			$this->useBigEndian=true;
		else
			throw new CException(Yii::t('yii','Invalid MO file: {file} (magic: {magic}).',
				array('{file}'=>$file,'{magic}'=>$magic)));

		if(($revision=$this->readInteger($fr))!=0)
			throw new CException(Yii::t('yii','Invalid MO file revision: {revision}.',
				array('{revision}'=>$revision)));

		$count=$this->readInteger($fr);
		$sourceOffset=$this->readInteger($fr);
		$targetOffset=$this->readInteger($fr);

		$sourceLengths=array();
		$sourceOffsets=array();
		fseek($fr,$sourceOffset);
		for($i=0;$i<$count;++$i)
		{
			$sourceLengths[]=$this->readInteger($fr);
			$sourceOffsets[]=$this->readInteger($fr);
		}

		$targetLengths=array();
		$targetOffsets=array();
		fseek($fr,$targetOffset);
		for($i=0;$i<$count;++$i)
		{
			$targetLengths[]=$this->readInteger($fr);
			$targetOffsets[]=$this->readInteger($fr);
		}

		$messages=array();
		for($i=0;$i<$count;++$i)
		{
			$id=$this->readString($fr,$sourceLengths[$i],$sourceOffsets[$i]);
			$pos = strpos($id,chr(4));

			if(($context && $pos!==false && substr($id,0,$pos)===$context) || (!$context && $pos===false))
			{
				if($pos !== false)
					$id=substr($id,$pos+1);

				$message=$this->readString($fr,$targetLengths[$i],$targetOffsets[$i]);
				$messages[$id]=$message;
			}
		}

		@flock($fr,LOCK_UN);
		@fclose($fr);

		return $messages;
	}
152402
public static function loadFromFile(string $file): Dom
    {
        $dom       = new Dom;
        self::$dom = $dom;

        return $dom->loadFromFile($file);
    }
1066891
public function loadFromFile(string $file, array $options = []): Dom
    {
        return $this->loadStr(file_get_contents($file), $options);
    }