Read a file

@param string $filename

@return string
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);
    }
354525
public function get($filename)
    {
        if ($this->exists($filename) && $this->isFile($filename)) {
            return file_get_contents($filename);
        }

        throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
    }
272025
public function parseFile($filename)
    {
        $data = json_decode(file_get_contents($filename), true);

        return (array)$this->parse($data, $filename);
    }
414906
public static function readLog($filename)
    {
        if (file_exists($filename)) {
            $content = file_get_contents($filename);
            $json = json_decode('[' . $content . ']', true);
        } else {
            $json = '{"msg":"The file does not exist."}';
        }
        return $json;
    }
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;
    }
1088194
public function readFileContents($fileName = null)
    {
        //====================================================================//
        // Safety Checks
        if (empty($fileName)) {
            return Splash::log()->err("ErrFileFileMissing");
        }
        //====================================================================//
        // Check if file exists
        if (!is_file($fileName)) {
            return Splash::log()->err("ErrFileNoExists", $fileName);
        }
        //====================================================================//
        // Check if file is readable
        if (!is_readable($fileName)) {
            return Splash::log()->err("ErrFileReadable", $fileName);
        }
        Splash::log()->deb("MsgFileRead", $fileName);
        //====================================================================//
        // Read File Contents
        return base64_encode((string) file_get_contents($fileName));
    }
111994
protected function getFileName(string $fileName): ?string
    {
        if (!$fileName) {
            return null;
        }

        if (filter_var($fileName, FILTER_VALIDATE_URL)) {

            try {
                $headers = (get_headers($fileName));
            } catch (Throwable $exception) {
                report($exception);
                sleep(1);

                if ($this->headerCallAttempts < 5) {

                    $this->headerCallAttempts++;

                    return $this->getFileName($fileName);
                }

                throw $exception;
            }

            $this->headerCallAttempts = 0;

            foreach ($headers as $header) {
                if (strpos($header, 'filename')) {
                    $name = explode('filename="', $header);
                    $name = rtrim($name[1], '"');

                    $name = explode('.', $name);

                    if (sizeof($name) > 1) {
                        return str_slug(implode('.', $name));
                    }
                }
            }
        }

        $explodeFileURL = explode('/', $fileName);
        $fileName = end($explodeFileURL);

        $explodedByParams = explode('?', $fileName);
        $fileName = head($explodedByParams);

        $string = sanitizeString(pathinfo($fileName, PATHINFO_FILENAME));

        if (strpos($fileName, '.') !== false && substr($fileName, -3) != 'php') {
            return $string . '.' . pathinfo($fileName, PATHINFO_EXTENSION);
        } else {
            return $string;
        }
    }
586637
public function getNameFromFile($filename)
	{
		$i = strrpos($filename, self::getSlash());

		if ($i!== false)
		{

			return substr($filename, $i+1);
		}
		else
		{
			return $filename;
		}
	}
158657
public static function read( $fileName )
	{
		$list	= array();
		if( !file_exists( $fileName ) )
			throw new RuntimeException( 'File "'.$fileName.'" is not existing' );
		$reader	= new FS_File_Reader( $fileName );
		$lines	= $reader->readArray();
		foreach( $lines as $line )
			if( $line = trim( $line ) )
				if( !preg_match( self::$commentPattern, $line ) )
					$list[]	= $line;
		return $list;
	}
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);
        }
    }
795117
public function
	Read(String $Filename=NULL) {

		if($Filename === NULL) $Filename = $this->Filename;
		else $this->Filename = $Filename;

		if(!$Filename)
		throw new Exception('No filename specified.');

		$Basename = basename($Filename);
		$Ext = NULL;

		if(strpos($Basename,'.') !== FALSE)
		$Ext = strtolower(explode('.',$Basename,2)[1]);

		////////
		////////

		if(!file_exists($Filename))
		throw new Exception("File {$Basename} not found.");

		if(!is_readable($Filename))
		throw new Exception("File {$Basename} is not readable.");

		////////
		////////

		if($Ext === 'json' || $this->Format === static::FormatJSON)
		$this->Data = json_decode(file_get_contents($Filename));

		elseif($Ext === 'phson' || $this->Format === static::FormatPHP)
		$this->Data = unserialize(file_get_contents($Filename));

		////////
		////////

		if(is_object($this->Data))
		$this->Data = (array)$this->Data;

		return $this;
	}
23244
protected function readFromCache($fileName)
    {
        $cacheFile = $this->getCacheFile($fileName);
        if (file_exists($cacheFile) && is_readable($cacheFile)) {
            include($cacheFile);
            if (isset($crudlexCacheContent)) {
                return $crudlexCacheContent;
            }
        }
        return null;
    }
228647
protected function getFilePath($filename)
    {
        if ($filename{0} == '/' || strstr($filename, ':') !== false) {
            return $filename;
        }

        return realpath(getcwd() . '/' . $filename);
    }
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);
    }
45652
public static function getFileNameWithoutExtension($fileName)
    {
        $matches = [];

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

        return '';
    }
1123726
public static function load($filename)
    {
        if (!is_readable($filename)) {
            throw new IOError($filename, 'File not found or file is not readable');
        }
        $content = @file_get_contents($filename);
        if ($content === false) {
            self::throwNativeError($filename);
        }
        return $content;
    }
787356
public function load($filename)
    {
        if ($t = $this->tryLoad($filename)) {
            return $t;
        }

        throw new Exception([
            'Unable to read template from file',
            'cwd'  => getcwd(),
            'file' => $filename,
        ]);
    }