Fetches the contents of the given file.
@param String $filename  Filename
@param String $type      File type, i.e. 'document' or 'image'
@return String           Content of the file. Throws an exception if file could not be read.
355939
public function fetchData($filename, $type) {
        $absPath    = $this->_getAbsPath($filename, $type);
        $sftpStream = $this->getSftpStream($absPath, 'rb');

        $content    = $this->_fetchAndCloseStream($sftpStream);

        if ($content !== false) {
            return $content;
        } else throw new Exception("Could not read {$absPath} on " . $this->getEnvironment());
    }
1000773
public function get($filename,$name,$type=''){
        if(!isset($this->contents[$filename])){
            if(!is_file($filename)) return false;
           $this->contents[$filename]=file_get_contents($filename);
        }
        $content=$this->contents[$filename];
        $info   =   array(
            'mtime'     =>  filemtime($filename),
            'content'   =>  $content
        );
        return $info[$name];
    }
59878
public static function parseFromFile($filename)
    {
        if (file_exists($filename) && is_readable($filename)) {
            return new self(file_get_contents($filename));
        } else {
            throw new \RuntimeException(sprintf("File %s is not readable, or doesn't exist.", $filename));
        }
    }
718142
public static String getContentType(String filename) {
		final ContentFileTypeMap map = ensureContentTypeManager();
		return map.getContentType(filename);
	}
219807
public static function get_file_type($filename)
    {
        $file_types = self::config()->get('file_types');

        // Get extension
        $extension = strtolower(self::get_file_extension($filename));

        if (isset($file_types[$extension])) {
            return _t(
                __CLASS__ . '.' . ucfirst($extension) . 'Type',
                $file_types[$extension]
            );
        }

        return 'unknown';
    }
953332
public static function get(string $filename, string $defaultValue = ''): string
    {
        if (!self::exist($filename)) {
            return $defaultValue;
        }
        return file_get_contents($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);
    }
586548
public function fetchEtag($filename, $type) {
        $baseDir    = $this->_getBaseDir();
        $absPath    = $baseDir . $this->_getRelPath($filename, $type);

        $session    = $this->getSshSession();

        $md5command = "cat {$absPath} | md5sum";
        $stream     = ssh2_exec($session, $md5command);
        $md5output  = $this->_fetchAndCloseStream($stream);

        if ($md5output) {
            $baddies = array(' ', '-', "\n");
            $md5output = str_replace($baddies, '', $md5output);
            return $md5output;
        } else throw new Exception("Could not fetch md5 sum of {$path}.");
    }
707865
protected function getFile($filename)
    {
        try {
            $api = $this->client->api('repositories');
            /* @var Repositories $api */
            $file = $api->getFile($this->raw['path_with_namespace'], $filename, 'master');
            if ('base64' === $file['encoding']) {
                return base64_decode($file['content'], true);
            }
        } catch (\Exception $e) {
            //file not found
        }
    }
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;
    }
393885
public function getContents(string $fileName)
    {
        if (!file_exists($this->__path . $fileName)) {
            return null;
        }
        $r = include $this->__path . $fileName;
        return $r === false ? null : $r;
    }
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,
        ]);
    }
9337
public function getFileByName($filename)
    {
        $files = $this->getFiles();
        foreach ($files as $file) {
            if ($filename == $file->file) {
                return $file;
            }
        }

        return null;
    }
1171473
public function getFileContent($fileName)
    {
        if (!in_array($fileName, $this->files, true))
            return false;

        return $this->archive->getFileContent($fileName);
    }
1168426
public static function load($filename)
    {

        $instance = new self;

        // Require GD library
        if (!extension_loaded('gd')) {
            throw new Exception('Required extension GD is not loaded.');
        }

        $instance->filename = $filename;

        $info = getimagesize($instance->filename);

        switch ($info['mime']) {

            case 'image/gif':
                $instance->image = imagecreatefromgif($instance->filename);
                break;

            case 'image/jpeg':
                $instance->image = imagecreatefromjpeg($instance->filename);
                break;

            case 'image/png':
                $instance->image = imagecreatefrompng($instance->filename);

                imagesavealpha($instance->image, true);
                imagealphablending($instance->image, true);

                break;

            default:
                throw new Exception('Invalid image: ' . $instance->filename);
                break;

        }

        $instance->original_info = array(
            'width' => $info[0],
            'height' => $info[1],
            'orientation' => $instance->get_orientation(),
            'exif' => function_exists('exif_read_data') ? $instance->exif = @exif_read_data($instance->filename) : null,
            'format' => preg_replace('/^image\//', '', $info['mime']),
            'mime' => $info['mime']
        );

        $instance->width = $info[0];
        $instance->height = $info[1];

        imagesavealpha($instance->image, true);
        imagealphablending($instance->image, true);

        return $instance;

    }
40851
public function readFile($filename)
    {
        if (!is_string($filename))
            throw new IniReadingException('The expected type is string');

        if (!file_exists($filename) || !is_readable($filename))
            throw new IniReadingException(sprintf("The file %s doesn't exist or is not readable", $filename));

        if (function_exists('file_get_contents')) {
            $ini = file_get_contents($filename);
        } elseif (function_exists('file')) {
            $ini = file($filename);
            if ($ini !== false)
                $ini = implode("\n", $ini);
        } elseif (function_exists('fopen') && function_exists('fread')) {
            $handle = fopen($filename, 'r');
            if (!$handle)
                return false;
            $ini = fread($handle, filesize($filename));
            fclose($handle);
        } else {
            return false;
        }

        if ($ini === false)
            throw new IniReadingException(sprintf('Impossible to read the file %s', $filename));

        return $this->readString($ini);
    }
1047461
private function readFile($filename)
    {
        if (!is_file($filename)) {
            throw new Exception('Failed to find file '.$filename);
        }
        if (!is_readable($filename)) {
            throw new Exception('File is not readable: '.$filename);
        }
        $contents = @file_get_contents($filename);
        if ($contents === false) {
            throw new Exception('Failed to read file '.$filename);
        }
        $contents = str_replace(array("\r\n", "\r"), "\n", $contents);
        $contents = preg_replace('/([a-z_\\\\]+)::class\b/i', "'\\1'", $contents);
        $this->contents = $contents;
    }