@param string $fileName

@return string
@throws RuntimeException
559216
public static function read($fileName)
    {
        if (!file_exists($fileName)) {
            throw new RuntimeException($fileName.' not exist');
        }
        if (!is_readable($fileName)) {
            throw new RuntimeException($fileName.' not readable');
        }

        $fh = fopen($fileName, "r");
        $data = fread($fh, filesize($fileName));
        fclose($fh);

        return $data;
    }
1305014
public function getFilePath($filename)
    {
        if (modules()) {
            $filePaths = modules()->getDirs('Views');
        } else {
            $filePaths = array_reverse($this->filePaths);
        }

        foreach ($filePaths as $filePath) {
            if (is_file($filePath . $filename . '.phtml')) {
                return $filePath . $filename . '.phtml';
                break;
            } elseif (is_file($filePath . 'errors' . DIRECTORY_SEPARATOR . $filename . '.phtml')) {
                return $filePath . 'errors' . DIRECTORY_SEPARATOR . $filename . '.phtml';
                break;
            }
        }
    }
1216823
private static function getClassName($filename)
    {
        $directoriesAndFilename = explode('/', $filename);
        $filename = array_pop($directoriesAndFilename);
        $nameAndExtension = explode('.', $filename);
        $className = array_shift($nameAndExtension);

        return $className;
    }
306969
public static function getFileExtension($filename)
    {
        $filename = basename($filename);

        // remove possible query string
        $pos = strpos($filename, '?');
        if ($pos !== false) {
            $filename = substr($filename, 0, $pos);
        }

        // retrieve the extension
        $pos = strrpos($filename, '.');
        if ($pos !== false) {
            return strtolower(substr($filename, $pos + 1));
        }

        return '';
    }
1318821
public function fromString($fileName)
    {
        $fileNameArray = $fileName ? explode('.', $fileName) : array();
        if(!$fileNameArray || count($fileNameArray) < 2){
            throw new Exception\InvalidArgumentException('File name not correct');
        }

        $fileExt = array_pop($fileNameArray);
        $fileNameMain = implode('.', $fileNameArray);
        $fileNameArray = explode(',', $fileNameMain);
        if(!$fileExt || !$fileNameArray || !$fileNameArray[0]){
            throw new Exception\InvalidArgumentException('File name not correct');
        }

        //remove empty elements
        $fileNameArray = array_filter($fileNameArray);
        $fileNameMain = array_shift($fileNameArray);
        $this->setExtension($fileExt);
        $this->setFilename($fileNameMain);

        $args = $fileNameArray;
        $argMapping = $this->argMapping;
        $params = array();
        foreach($args as $arg){
            if(!$arg){
                continue;
            }
            if(strlen($arg) < 3 || strpos($arg, '_') !== 1){
                continue;
            }
            $argKey = $arg{0};
            if(isset($argMapping[$argKey])){
                $arg = substr($arg, 2);
                if($arg !== ''){
                    $params[$argMapping[$argKey]] = $arg;
                }
            }
        }

        $this->fromArray($params);
        return $params;
    }
430693
protected function loadTokenFromFile($filename)
    {
        if (strpos($filename, '/') !== 0 && strpos($filename, '\\') !== 0) {
            $filename = $this->config->getUserConfigDir() . '/' . $filename;
        }

        $content = file_get_contents($filename);
        if ($content === false) {
            throw new \RuntimeException('Failed to read file: ' . $filename);
        }

        return trim($content);
    }
283394
protected static function updateConfigFile( $filename )
	{
		if( ( $content = file_get_contents( $filename ) ) === false ) {
			throw new \RuntimeException( sprintf( 'File "%1$s" not found', $filename ) );
		}

		if( self::addAsseticBundle( $content ) === true ) {
			$fs = new Filesystem();
			$fs->dumpFile( $filename, $content );
		}
	}
1345484
public function getFile($filename) {

        $filename = realpath(__DIR__.'/../headers/'.$filename.'.txt');

        if(!file_exists($filename)) throw new \Exception('Filename doesnt exist.');

        return file_get_contents($filename);
    }
1345447
protected function get_mimetype_from_filename($filename) {
        $mimetype = 'application/unknown';
        $types = core_filetypes::get_types();
        $fileextension = '.bin';
        if (strpos($filename, '.') !== false) {
            $fileextension = substr($filename, strrpos($filename, '.') + 1);
        }

        if (isset($types[$fileextension])) {
            $mimetype = $types[$fileextension]['type'];
        }
        return $mimetype;
    }
86950
protected function readConfig($filename)
    {
        if (empty($filename) || !is_string($filename) || !file_exists($filename)) {
            throw new RuntimeException(sprintf('Configuration file "%s" was not found.', $filename));
        }
        $this->_modifiedTime = max($this->_modifiedTime, filemtime($filename));

        if (function_exists('parse_ini_file')) {
            return parse_ini_file($filename, true);
        } else {
            return parse_ini_string(file_get_contents($filename), true);
        }
    }
45652
public static function getFileNameWithoutExtension($fileName)
    {
        $matches = [];

        if (is_string($fileName) && (bool)preg_match('|(.+)\.(.+)|', $fileName, $matches)) {
            return $matches[1];
        }

        return '';
    }
200216
public static File toFile(final String filename) {
        if (filename == null) {
            return null;
        }
        String f;
        try {
            f = URLDecoder.decode(filename, UTF8);
        } catch (final UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        f = f.replace(WINDOWS_SEPARATOR, File.separator).replace(UNIX_SEPARATOR, File.separator);
        return new File(f);
    }
610201
protected function parseFileName($fileName)
    {
        return preg_replace_callback('#(\[.*\])#U', function ($matches) {
            $format = str_replace(['[',']'], [], $matches[1]);

            return $this->now->format($format);
        }, $fileName);
    }
773240
public function read($filename)
    {
        if (!is_readable($filename)) {
            throw new FileNotFoundException(sprintf('File "%s" does not exist.', $filename), 0, null, $filename);
        }

        return file_get_contents($filename);
    }
733123
public function getTemplate($name)
    {
        if (!$this->hasTemplate($name)) {
            throw new \RuntimeException("Template with name \"".$name."\" is not exist");
        }

        $filename = $this->templateMap[$name];

        if (!file_exists($filename)) {
            throw new \RuntimeException("Invalid template filename with name \"".$name."\"");
        }

        return $filename;
    }
359561
protected function getXsltUriFromFilename($filename)
    {
        // Windows requires an additional / after the scheme. If not provided then errno 22 (I/O Error: Invalid
        // Argument) will be raised. Thanks to @FnTmLV for finding the cause. See issue #284 for more information.
        // An exception to the above is when running from a Phar file; in this case the stream is handled as if on
        // linux; see issue #713 for more information on this exception.
        if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' && ! \Phar::running()) {
            $filename = '/' . $filename;
        }

        return 'file://' . $filename;
    }
913123
public function read($fileName)
    {
        $parsedYaml = $this->readFromCache($fileName);
        if ($parsedYaml !== null) {
            return $parsedYaml;
        }

        try {
            $fileContent = file_get_contents($fileName);
            $parsedYaml  = Yaml::parse($fileContent);
            if (!is_array($parsedYaml)) {
                $parsedYaml = [];
            }
            $this->writeToCache($fileName, $parsedYaml);
            return $parsedYaml;
        } catch (\Exception $e) {
            throw new \RuntimeException('Could not read Yaml file '.$fileName, $e->getCode(), $e);
        }
    }