Open, parse, and return the template file.
@param string $file the template file name
@return string
438959
public function fetch($file)
    {
        $templateFile = $this->findTemplateFile($file);

        if (empty($templateFile)) {
            throw new Exception("Template file does not exists: $file");            
        }

        extract($this->vars);
        ob_start();
        include $templateFile;
        $buffer = ob_get_contents();
        ob_end_clean();
        return $buffer;
    }
492874
private function openFile($file)
    {
        if (is_resource($file)) {
            if (get_resource_type($file) !== 'stream') {
                throw new \InvalidArgumentException('The given resource is not a file handle.');
            }
        } else {
            $filename = (string) $file;

            if (!is_file($filename) || !is_readable($filename)) {
                throw new \LogicException(sprintf('File "%s" could not be opened.', $filename));
            }

            $file = fopen($filename, 'r');
        }

        return $file;
    }
1275273
public static function getMime($file)
    {
        $fileInfo = finfo_open(FILEINFO_MIME_TYPE);
        $mime = finfo_file($fileInfo, $file);

        return empty($mime) ? : $mime;
    }
264720
public function parseFile($file)
    {
        if (!file_exists($file)) {
            return false;
        }
        $fh = fopen($file, 'r');
        if (!$fh) {
            return false;
        }
        $ret = $this->parseHandle($fh);
        fclose($fh);
        return $ret;
    }
414130
public static function read($file)
    {
        if (!is_readable($file) || !is_file($file)) {
            return;
        }

        $data = file_get_contents($file);

        if ($data === false) {
            return;
        }

        return $data;
    }
1069890
public function parse($file)
    {
        $result = null;
        $this->hook->attach('help.render.before', $file, $result, $this);

        if (isset($result)) {
            return (string) $result;
        }

        $result = $this->markdown->render(file_get_contents($file));
        $this->hook->attach('help.render.after', $file, $result, $this);
        return (string) $result;
    }
858180
public function build($file = null)
    {
        $prepared = preg_replace_callback('/%.*%/U', function ($m) {
            if ($m[0] === '%phpdoc%') {
                $string = '/**';
                foreach ($this->components as $name => $classes) {
                    $string .= PHP_EOL . ' * @property ' . implode('|', $classes) . ' $' . $name;
                }
                $string .= PHP_EOL . ' */';
                return $string;
            }
            return $m[0];
        }, $this->template);
        if ($file === null) {
            return $prepared;
        }
        return (bool)file_put_contents($file, $prepared);
    }
750843
private function open_image( $file )
	{
		$sfile = new SFile($file);

		// If $file isn't an array, we'll turn it into one
		if ( !is_array($file) ) {
			$file = array(
				'type'		=> $sfile->getMimeType(),
				'tmp_name'	=> $file
			);
		}

		$mime = $file['type'];
		$file_path = $file['tmp_name'];

		switch ( $mime )
		{
			case 'image/pjpeg': // IE6
			case 'image/jpeg':	$img = @imagecreatefromjpeg( $file_path );	break;
			case 'image/gif':	$img = @imagecreatefromgif( $file_path );	break;
			case 'image/png':	$img = @imagecreatefrompng( $file_path );	break;
			default:				$img = false;								break;
		}

		return $img;
	}
1017421
public static function getFile( $file ) {
		$file = Storage::getFile( Route::DOCUMENT_ROOT() . 'app/config/' . $file . '.json' );
		$out  = Parser::json( $file );

		return $out;
	}
734158
protected function getFile($file)
    {
        $mapping = [
            '%environment%' => $this->runtime->getEnvironment(),
        ];

        if ($this->runtime->getHostName() !== null) {
            $mapping['%host%'] = $this->runtime->getHostName();
        }

        if ($this->runtime->getReleaseId() !== null) {
            $mapping['%release%'] = $this->runtime->getReleaseId();
        }

        $options = $this->getOptions();
        return str_replace(
            array_keys($mapping),
            array_values($mapping),
            $options[$file]
        );
    }
1008679
protected static function _parse($file) {
		$header = '';
		$content = '';

		if (!$stream = fopen($file, 'r')) {
			throw new Exception('Failed to open file.');
		}

		$isHeader = false;

		while (!feof($stream)) {
			$line = rtrim(fgets($stream));

			if ($line === '---') {
				$isHeader = !$isHeader;
				continue;
			}
			if ($isHeader) {
				$header .= $line . "\n";
			} else {
				$content .= $line . "\n";
			}
		}
		if ($header) {
			$info = Yaml::parse($header);
		} else {
			$info = [];
		}

		fclose($stream);
		return [$info, $content];
	}
581462
public static function fromFile(string $file, string $package)
    {
        $html = '';
        if (file_exists($file)) {
            $html = file_get_contents($file);
            $html = preg_replace(
                "/{(.*)template(.*)}/", "/templates/" . template() . "/" . $package, 
                $html
            );
        }
        return $html;
    }
932749
private function getRealFilename(string $file): string
    {
        if (strpos($file, 'vfs://') !== false) {
            return $file;
        }

        return $this->loader->getSourceContext($file)->getPath();
    }
761297
protected function _findFile($file)
    {
        foreach ($this->_settings['paths'] as $path) {
            $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
            if (file_exists($path . $file)) {
                return $path . $file;
            }
        }
        return $file;
    }
207898
protected function load_file($file)
	{
		$contents = $this->parse_vars(file_get_contents($file));
		return \Format::forge($contents, 'yaml')->to_array();
	}
124178
private function templateEngineParse($file)
	{
		if (Config::get('@.TEMPLATE_ENGINE_ON'))
		{
			$cacheFileName = Config::get('@.TEMPLATE_CACHE_FOLDER') . '/' . md5($file);
			// 启用模版引擎
			$cacheFile = Cache::getInstance('DefaultFile')->getFileName($cacheFileName);
			if($this->cacheIsExpired($cacheFile))
			{
				// 判断模版缓存是否存在
				$t=$this->parseTemplate($file);
				// 没有模版缓存，解析模版并写入缓存
				Cache::set($cacheFileName, $t, array ('raw'=>true));
			}
			// 执行
			return $cacheFile;
		}
		else
		{
			return $file;
		}
	}
725121
private function openImage($file)
        {

            // If $file isn't an array, we'll turn it into one.
            if (!is_array($file)) {
                $file_dimensions = getimagesize($file);
                $file = array(
                    'type'      => Inflector::lower($file_dimensions['mime']),
                    'tmp_name'  => $file
               );
            }

            $mime = $file['type'];
            $file_path = $file['tmp_name'];

            // Confirm that the file actually exists.
            if (!file_exists($file_path)) {
                throw new Exception('Could not find file: ' . $file_path . '. It doesn\'t seem to exist.');
            }

            switch ($mime) {
                case 'image/pjpeg': // IE6
                case File::mime('jpg'): $img = @imagecreatefromjpeg($file_path);  break;
                case File::mime('gif'): $img = @imagecreatefromgif($file_path);   break;
                case File::mime('png'): $img = @imagecreatefrompng($file_path);   break;
                default:                $img = false;                            break;
            }

            return $img;
        }