Factory method to get the group of a file.

@param string    $filename

@return Group

@throws PosixNotAvailableException
@throws \Exception
485900
public static function createFromFileGroup($filename)
    {
        if (!file_exists($filename)) {
            throw new \InvalidArgumentException('Invalid file name provided.');
        }
        if (!function_exists('posix_getgrgid')) {
            throw new PosixNotAvailableException(
                'Could not retrieve information about the operating system group because POSIX functions '
                . 'are not available to your PHP executable.'
            );
        }
        if (false === $gid = \filegroup($filename)) {
            throw new \Exception('Could not get the group of the file "' . $filename . '".');
        }
        return new Group($gid);
    }
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;
    }
382703
public function getGroup($groupName)
    {
        return isset($this->groups[$groupName]) ? $this->groups[$groupName] : null;
    }
1225858
public static function loadFromFile($filename)
	{
		$xmlFile = substr($filename, 0, -4) . '/plugin.xml';
		if (file_exists($xmlFile))
		{
			return self::loadFromXmlFile($xmlFile);
		}
		else
		{
			return self::loadFromPhpFile($filename);
		}
	}
1213456
public function parseFile($filename)
    {
        libxml_use_internal_errors(true);
        $data = simplexml_load_file($filename, null, LIBXML_NOERROR);

        return (array)$this->parse($data, $filename);
    }
175395
public static function fromFile(string $filename = ''): self
    {
        if (!\file_exists($filename)) {
            throw new \Exception($filename.' does not exist');
        }
        $contents = \file_get_contents($filename);
        if (!\is_string($contents)) {
            throw new \Exception('Could not read file contents');
        }
        return self::fromData($contents);
    }
1066111
public function parseFile($filename)
    {
        try {
            $data = YamlParser::parseFile($filename, YamlParser::PARSE_CONSTANT);
        } catch (Exception $exception) {
            throw new ParseException(
                [
                    'message'   => 'Error parsing YAML file',
                    'exception' => $exception,
                ]
            );
        }

        return (array)$this->parse($data);
    }
937484
public function open($filename)
    {

        if (!is_file($filename)) return false;

        $this->file       = @(string)$filename;
        $this->group      = @(int)filegroup($filename);
        $this->owner      = @(int)fileowner($filename);
        $this->size       = @(int)filesize($filename);
        $this->type       = @(string)filetype($filename);
        $this->accessed   = @(int)fileatime($filename);
        $this->changed    = @(int)filectime($filename);
        $this->modified   = @(int)filemtime($filename);
        $this->permission = @(int)fileperms($filename);
        $this->f_inode    = @ fileinode($filename);
        $this->writeable  = @(bool)is_writable($filename);
        $this->readable   = @(bool)is_readable($filename);
        $this->mime_type  = @(string)mime_content_type($filename);
        $this->_get_path();
        $this->_extract_filename();
        $this->_extract_file_extension();

        return true;
    }
1372470
static public function createFromFile($filename) {
		if (!file_exists($filename))
			throw new Exception('Invalid (filename) parameter! File does not exist!');

		$image_info = getimagesize($filename);
		if ($image_info === false)
			throw new Exception('Invalid (filename) parameter! File is corrupted!');

		switch ($image_info[2]) {
			case IMAGETYPE_JPEG:
			case IMAGETYPE_JPEG2000:
				$image = imagecreatefromjpeg($filename);
				break;
			case IMAGETYPE_PNG:
				$image = imagecreatefrompng($filename);
				break;
			case IMAGETYPE_GIF:
				$image = imagecreatefromgif($filename);
				break;
			case IMAGETYPE_WBMP:
				$image = imagecreatefromwbmp($filename);
				break;
			case IMAGETYPE_BMP:
				$image = imagecreatefrombmp($filename);
				break;
			default:
				throw new Exception('Unknown image format!');
				break;
		}

		return new self($image);
	}
197783
public function getConfigByFilename(string $filename)
    {
        if (!isset($this->config[$filename])) {
            throw new Exception(
                'The file '.$filename.' has not been found',
                $this::ERR_FILE_NOT_FOUND
            );
        }
        
        return $this->config[$filename];
    }
439278
public function getGroup(string $groupName) : DataModifierGroup
    {
        if (false === $this->hasGroup($groupName)) {
            throw new DataModifierGroupNotFoundException($groupName);
        }

        return $this->dataModifierGroups[$groupName];
    }
157353
protected function parseOptions($filename)
    {
        $options = $this->loadYaml($filename);
        if (is_array($options)) {
            $this->options = $options;
        } else {
            throw new \InvalidArgumentException(sprintf('Settings contained by "%s" are not valid as the settings are not contained by an array: "%s"', $filename, gettype($options)), __LINE__);
        }
        return $this;
    }
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;
    }
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);
    }
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;
	}
276797
public static function fromFile($filename): self
    {
        if (!is_readable($filename) ||
             false === ($str = file_get_contents($filename))) {
            throw new \RuntimeException("Failed to read $filename.");
        }
        return self::fromString($str);
    }
46651
protected function getFile($filename)
    {
        try {
            $file = $this->client->repos()->contents()->show($this->raw['owner']['login'], $this->raw['name'], $filename);
            if ('base64' === $file['encoding']) {
                return base64_decode($file['content'], true);
            }
        } catch (\Exception $e) {
            //file not found
        }
    }