Check if the file is readable across all platforms
@param string $filename
@return bool The filename matches with your spelling name.
349231
public static function isReadable($filename)
	{
		if (!is_readable($filename))
			return false;

		if ((self::isWindowsOS() || self::isMacOS()) && (count(glob($filename . '*')) == 0))
			throw new \Xmlnuke\Core\Exception\CaseMismatchException(
				'Your operating system is not case sensitive and it can find the file "' . $filename . '" ' .
				'with different uppercase and lowercase combination in your name. ' .
				'However Xmlnuke will not accept it for ensure your code will run on any platform.'
			);
		else
			return true;
	}
506673
public static function canOpenArchive($fileName)
    {
        self::checkRequirements();

        $type = self::detectArchiveType($fileName);
        if ($type !== false && self::canOpenType($type)) {
            return true;
        }

        return false;
    }
45652
public static function getFileNameWithoutExtension($fileName)
    {
        $matches = [];

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

        return '';
    }
467239
public static function detectMimeType($fileName)
    {
        $fileInfo = finfo_open(FILEINFO_MIME_TYPE);
        $mime = finfo_file($fileInfo, $fileName);
        finfo_close($fileInfo);

        return $mime;
    }
1351514
protected function display_name_from_file($filename) {
        $pos = core_text::strrpos($filename, '.');
        if ($pos) { // Want to skip if $pos === 0 OR $pos === false.
            $filename = core_text::substr($filename, 0, $pos);
        }
        return str_replace('_', ' ', $filename);
    }
699929
public function get($filename)
    {
        if (!$stream = $this->readStream($filename)) {
            return false;
        }

        $contents = stream_get_contents($stream);

        fclose($stream);

        return $contents;
    }
213190
static public function touch($filename)
	{
	    $ret = true;
	    if ($filename && !file_exists($filename)) {
	        $ret = static::write($filename, '');
	    }
	    return $ret;
	}
152683
public function match(string $filename): bool
    {
        $extension = pathinfo($filename, PATHINFO_EXTENSION);
        return strtolower($extension) == $this->extension;
    }
519920
public static function isJpegFile($filename)
    {
        try {
            $image = new ImageFile($filename);
            if (strtolower($image->getMime()) !== @image_type_to_mime_type(IMAGETYPE_JPEG)) {
                return false;
            }

            return true;
        } catch (\RuntimeException $ex) {
            return false;
        }
    }
118673
function isWriteable( $filename = false )
    {
        if ( !$filename )
            $filename = $this->FileName;
        return $this->doIsWriteable( $filename );
    }
306011
private function readFile($filename)
    {
        if (!file_exists($filename)) {
            throw new \Exception(sprintf('File not found: %s', $filename));
        }
        if (!is_readable($filename) || ($content = file_get_contents($filename)) === false) {
            throw new \Exception(sprintf('Failed to read file: %s', $filename));
        }

        return $content;
    }
1175481
protected function shouldBeExecutable($filename)
    {
        foreach ($this->config->getExecutableFiles() as $exFile) {
            if ($filename === $exFile) {
                return true;
            }
        }
        return false;
    }
774565
public function checkFile( $fileName )
	{
		$output = shell_exec('php -l "'.$fileName.'"');
		if( preg_match( "@^No syntax errors detected@", $output	) )
			return TRUE;
		$this->error	= $output;
		return FALSE;
	}
1056336
public function equals( $fileName )
	{
		$toCompare	= FS_File_Reader::load( $fileName );
		$thisFile	= FS_File_Reader::load( $this->fileName );
		return( $thisFile == $toCompare );
	}
733296
public static function valid($filename = null)
	{
		if (!$filename)
		{
			return false;
		}

		if (preg_match("/^\s*http[s]{0,1}:/i", $filename))
		{
			return false;
		}
		if (preg_match("/^\s*[\/]{0,1}index.php\?/i", $filename))
		{
			return false;
		}
		// Disallow windows drive letter
		if (preg_match("/^\s*[.]:/", $filename))
		{
			return false;
		}
		// Disallow \
		if (strpos($filename, '\\'))
		{
			return false;
		}
		// Disallow ..
		if (strpos($filename, '..'))
		{
			return false;
		}

		return true;
	}
506609
public function read($fileName)
    {
        $path = $this->getPathBase($fileName);

        if (!file_exists($path)) {
            return;
        }

        $data = file_get_contents($path);
        return $this->data = unserialize($data);
    }
520570
protected function isCached($filename)
    {
        if (! empty($this->cacheDir)) {
            return false;
        }

        $cacheFile = $this->cacheDir . DIRECTORY_SEPARATOR . $filename . ".cache";

        if (file_exists($cacheFile)
            && is_array($this->cacheContent = include($cacheFile))
            && $this->cacheContent["_chk"] == filemtime($cacheFile)
        ) {
            return true;
        }

        return false;
    }