Load an API token from a file.

@param string $filename
A filename, either relative to the user config directory, or absolute.

@return string
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);
    }
426329
public static function parse($filename = null)
    {
        // fetch netrc filename if it is not specified
        if (!$filename) {
            if (!$homePath = getenv('HOME')) {
                throw new ParseException("HOME environment variable must be set for correctly netrc handling");
            }
            if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                $filename = strtr($homePath, '\\', '/') . '/_netrc';
            } else {
                $filename = rtrim($homePath, '/') . '/.netrc';
            }
        }
        $filename = realpath($filename);

        // check that netrc file is available
        if (!file_exists($filename) || !is_readable($filename) || !$content = file_get_contents($filename)) {
            throw new ParseException("netrc file does not exist or is not readable");
        }

        // parse file
        $parser = new Parser();
        return $parser->parse($content);
    }
623266
public function load(string $fileName)
    {
        if (null === $this->handle) {
            throw new DriverException('The image ' . $fileName . ' seems to be broken.');
        }

        return $this->handle;
    }
636708
public static function load( $fileName )
	{
		$parser	= new XML_DOM_Parser();
		$xml	= FS_File_Reader::load( $fileName );
		$tree	= $parser->parse( $xml );
		return $tree;
	}
1172500
public static function getTokens(string $filename): array
    {
        $tokens = token_get_all(file_get_contents($filename));

        $line = 0;
        foreach ($tokens as &$token) {
            if (isset($token[self::LINE])) {
                $line = $token[self::LINE];
            }

            if (!is_array($token)) {
                $token = [$token, $token, $line];
            }

            unset($token);
        }

        return $tokens;
    }
969825
protected function _getUri($filename): string {
        $this->_verifyPath();
        // Note: AWS SDK does not want the URI to start with a slash, as opposed to the old Zend
        // Framework implementation.
        $path = trim($this->_config['path'], '/');
        return $path . '/' . $filename;
    }
64515
function _loadFile($filename)
    {
        if (file_exists($filename))
        {
            $info = getimagesize($filename);
            $filedata['width'] = $info[0];
            $filedata['height'] = $info[1];
            ($filedata['width'] >= $filedata['height']) ? ($filedata['bias'] = IMAGE_TOOLBOX_BIAS_HORIZONTAL) : ($filedata['bias'] = IMAGE_TOOLBOX_BIAS_VERTICAL);
            $filedata['aspectratio'] = $filedata['width'] / $filedata['height'];
            $filedata['type'] = $info[2];

            if ($this->_types[$filedata['type']]['supported'] < 1)
            {
                //trigger_error($this->_error_prefix . 'Imagetype ('.$this->_types[$filedata['type']]['ext'].') not supported for reading.', E_USER_ERROR);
                return null;
            }
            switch ($filedata['type'])
            {
                case 1:
                    $dummy = imagecreatefromgif($filename);
                    $functionname = $this->_imagecreatefunction;
                    $filedata['resource'] = $functionname($filedata['width'], $filedata['height']);
                    imagecopy($filedata['resource'], $dummy, 0, 0, 0, 0, $filedata['width'], $filedata['height']);
                    imagedestroy($dummy);
                    break;

                case 2:
                    $filedata['resource'] = imagecreatefromjpeg($filename);
                    break;

                case 3:
                    $dummy = imagecreatefrompng($filename);
                    if (imagecolorstotal($dummy) != 0)
                    {
                        $functionname = $this->_imagecreatefunction;
                        $filedata['resource'] = $functionname($filedata['width'], $filedata['height']);
                        imagecopy($filedata['resource'], $dummy, 0, 0, 0, 0, $filedata['width'], $filedata['height']);
                    }
                    else
                    {
                        $filedata['resource'] = $dummy;
                    }
                    unset($dummy);
                    break;

                default:
                    //trigger_error($this->_error_prefix . 'Imagetype not supported.', E_USER_ERROR);
                    return null;
            }
            return $filedata;
        }
        else
        {
            //trigger_error($this->_error_prefix . 'Imagefile (' . $filename . ') does not exist.', E_USER_ERROR);
            return null;
        }
    }
1150856
protected function fileOrUrl($filename)
    {
        $options = array();
        if (!empty($this->httpBasicAuth) || !empty($this->httpUserAgent)) {
            $options['http'] = array();
            $options['http']['header'] = array();

            if (!empty($this->httpBasicAuth)) {
                $username  = $this->httpBasicAuth['username'];
                $password  = $this->httpBasicAuth['password'];
                $basicAuth = base64_encode("{$username}:{$password}");

                array_push($options['http']['header'], "Authorization: Basic {$basicAuth}");
            }

            if (!empty($this->httpUserAgent)) {
                array_push($options['http']['header'], "User-Agent: {$this->httpUserAgent}");
            }
        }

        $context = stream_context_create($options);

        if (($lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES, $context)) === false) {
            throw new \Exception("The file path or URL '{$filename}' does not exist.");
        }

        return $lines;
    }
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
        }
    }
15658
public function load(string $filename)
    {
        if (!file_exists($filename)) {
            Throw new AppException(sprintf('Languagefile "%s" does not exist.'), $filename);
        }

        $loaded = include $filename;

        if ($loaded) {
            $array = new Flatten($loaded);
            $array->setPreserveFlaggedArraysFlag(true);
            $this->strings = array_replace($this->strings, $array->flatten());
        }
    }
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);
    }
1056751
public static function load( $fileName )
	{
		$file	= new FS_File_Reader( $fileName );
		if( !$file->exists() )
			throw new Exception( "File '".$fileName."' is not existing." );
		$xml	= $file->readString();
		$parser	= new XML_OPML_Parser();
		return $parser->parse( $xml );
	}
2084
protected function load($filename)
    {
        $lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
        if ($lines === false) {
            throw new \InvalidArgumentException('Invalid file');
        }

        $entry      = self::newEntry();
        $lastKw     = null;
        $lastIndex  = null;

        foreach ($lines as $line) {
            if ($line[0] === '#') {
                $this->maybePushEntry($entry);
                if (strlen($line) === 1) {
                    continue;
                }
                switch ($line[1]) {
                    case ' ':   # Translator comment
                        break;
                    case '.':   # Extracted comment
                        break;
                    case ':':   # File/line reference
                        break;
                    case ',':   # Flags
                        break;
                    case "|":   # Previous information
                        # The initial marker is followed by a keyword
                        # (either "msgid", "msgctxt" or "msgid_plural"),
                        # detailing what the previous information was.
                        break;
                }
                continue;
            }

            $line   = ltrim($line, " \t");
            $len    = strlen($line);

            // Reset keyword index on new entry
            if (!count($entry['msgstr'])) {
                $lastIndex = null;
            }

            // Look for continuation strings.
            if (strlen($line) >= 2 && $line[0] === '"' && $line[$len-1] === '"') {
                // We found a string, but it has no predecessor.
                if ($lastKw === null) {
                    throw new \InvalidArgumentException();
                }

                $line   = stripcslashes((string) substr($line, 1, -1));

                if ($lastKw === 'msgstr') {
                    $index = $lastIndex === null ? 0 : $lastIndex;
                } else {
                    $index = null;
                }

                if ($index === null) {
                    if (is_array($entry[$lastKw])) {
                        throw new \InvalidArgumentException();
                    } else {
                        $entry[$lastKw] .= $line;
                    }
                } else {
                    if (!is_array($entry[$lastKw])) {
                        throw new \InvalidArgumentException();
                    } else {
                        $entry[$lastKw][$index] .= $line;
                    }
                }
                continue;
            }

            $kwLen  = strcspn($line, " \t");
            $kw     = (string) substr($line, 0, $kwLen);
            $index  = null;
            $line   = ltrim((string) substr($line, $kwLen), " \t");

            $brkOpen    = strpos($kw, '[');
            $brkClose   = strpos($kw, ']');
            if ($brkOpen !== false || $brkClose !== false) {
                if ($brkOpen === false || $brkClose === false || $brkClose < $brkOpen) {
                    throw new \InvalidArgumentException();
                }

                $nlen = strspn($kw, '1234567890', $brkOpen + 1, $brkClose - $brkOpen - 1);
                if ($nlen === 0 || $nlen !== $brkClose - $brkOpen - 1) {
                    throw new \InvalidArgumentException();
                }

                $index  = (int) substr($kw, $brkOpen + 1, $nlen);
                $kw     = (string) substr($kw, 0, $brkOpen);
            }

            if (strlen($line) < 2 || $line[0] !== '"' || $line[strlen($line)-1] !== '"') {
                throw new \InvalidArgumentException();
            }
            $line = stripcslashes((string) substr($line, 1, -1));

            switch ($kw) {
                case "msgstr":
                    if ($index === null) {
                        if (isset($entry[$kw][0])) {
                            throw new \InvalidArgumentException();
                        }
                        $entry[$kw][0] = $line;
                    } else {
                        if (array_key_exists($index, $entry[$kw])) {
                            throw new \InvalidArgumentException();
                        }
                        $entry[$kw][$index] = $line;
                        $lastIndex = $index;
                    }
                    break;

                case "msgctxt":
                    // Intentional fall-through
                case "msgid":
                    $this->maybePushEntry($entry);
                    // Intentional fall-through
                case 'msgid_plural':
                    if ($index !== null || isset($entry[$kw])) {
                        throw new \InvalidArgumentException();
                    }
                    $entry[$kw] = $line;
                    break;

                default:
                    throw new \InvalidArgumentException();
            }
            $lastKw = $kw;
        }

        // Push the last entry.
        $this->maybePushEntry($entry);
    }
455691
public static function load(string $filename) {
		$data = parse_ini_file($filename, true);
		if (!empty($data['registry'])) {
			foreach ($data['registry'] as $k => $v) {
				array_key_set(self::$settings, explode('.', $k), $v);
			}
		}
	}
189585
public static function fromFile($fileName) {
        if (!file_exists($fileName))
            throw new SettingsException("file $fileName does not exist");
        return static::fromString(file_get_contents($fileName), dirname($fileName));
    }
986184
protected function loadYamlFile( $fileName )
	{
		$array	= FS_File_YAML_Reader::load( $fileName );
		foreach( $array as $sectionName => $sectionData )
			foreach( $sectionData as $key => $value )
				$this->pairs[$sectionName.".".$key]	= $value;
	}
1238317
protected function load()
    {
        if (false !== ($token = @file_get_contents($this->getFilename()))) {
            $this->token = trim($token);
        } else {
            throw new \Exception(sprintf('Token could not be loaded from "%s"', $this->getFilename()));
        }
    }