Filter the file

@param SPLFileInfo $file

@return bool
166749
public function filter(\SPLFileInfo $file)
    {
        foreach ($this->filterlist as $filter) {
            if (! $filter->filter($file)) {
                return false;
            }
        }
        return true;
    }
1037554
protected function load(SplFileInfo $file)
    {
        // File info
        $this->filename = $file->getBasename();
        $this->sourcePath = $file->getRelativePath();

        // Load the file
        $data = $file->getContents();

        list($content, $meta) = $this->splitContentMeta($data);

        // Parse meta
        $meta = Yaml::parse($meta) ?: [];

        // Parse content
        switch ($file->getExtension()) {
            case 'md':
            case 'markdown':
                $content = Markdown::parse($content);
                $this->type = self::TYPE_MARKDOWN;
                break;
            case 'tx':
            case 'textile':
                $content = Textile::parse($content);
                $this->type = self::TYPE_TEXTILE;
                break;
        }

        // Set content
        $this->content = $content;
        $this->meta = $meta;

        // Ensure local URLs are absolute
        foreach($this->meta as $key=>$value) {
            if (preg_match('/\burl\b|.*_url\b/', $key)) {
                $this->meta[$key] = $this->builder->getUrl($value);
            }
        }

        // Set target
        $this->setTarget($file);

        // Pagination enabled
        $this->paginate = isset($this->meta['paginate']);

        // Get parent page
        if ($root = dirname(dirname($this->target))) {
            if ($root !== DIRECTORY_SEPARATOR) {
                $this->parentId = ltrim($root, '/');
            }
        }

        // Set URL
        $this->url = '/' . trim(str_replace([DIRECTORY_SEPARATOR, '//'], ['/', '/'], $this->target), '/');

        // Remove "index.html" from the end, this provides a cleaner URL
        if (substr($this->url, -10) === 'index.html') {
            $this->url = substr($this->url, 0, -10);
        }

        // Set basic values
        $this->id = trim($this->url, '/') ?: 'root';
        $this->title = $this->get('title');
        $this->url = $this->builder->getUrl($this->url);

        // Set Description
        if ($this->has('description')) {
            $this->description = $this->get('description');
        }
        else {
            $this->description = $this->getDescription();
        }
    }
657761
protected function filterFile($file)
    {
        if (is_string($file)) {
            $this->file = $file;
        } elseif (is_resource($file)) {
            $this->stream = new Stream($file);
        } elseif ($file instanceof StreamInterface) {
            $this->stream = $file;
        } else {
            throw new \InvalidArgumentException('The file resource is not readable.');
        }
    }
742397
protected function parse(\SplFileInfo $file): array
    {
        try {
            $config = \Toml::parseFile($file->getRealPath());
        } catch (\Exception $e) {
            throw new ConfigurationParseException('Unable to parse config file: ' . $e->getMessage());
        }

        return $config;
    }
1035214
public function removeFromLibrary(File $file)
    {
        if(!$this->containsFile($file)){
            return false;
        }
        if($this->whitelistContainsFile($file)){
            $this->removeFromWhitelist($file);
        }
        $file->delete();
        return !$this->containsFile($file);
    }
1129569
protected function getFilePieces(\SplFileInfo $file)
    {
        $key = $file->getBasename();
        if (!array_key_exists($key, $this->filePieces)) {
            $pieces = explode('.', $file->getBasename());
            if (count($pieces) < 3) {
                return true;
            }
            $extension = array_pop($pieces);
            $locale = array_pop($pieces);
            $domain = implode('.', $pieces);

            $this->filePieces[$key] = [
                self::FILE_PIECE_DOMAIN => $domain,
                self::FILE_PIECE_LOCALE => $locale,
                self::FILE_PIECE_EXTENSION => $extension,
            ];
        }

        return $this->filePieces[$key];
    }
492624
protected function normalizeFileInfo(SplFileInfo $file)
    {
        if (! $file->isLink()) {
            $normalized = [
                'type'      => $file->getType(),
                'path'      => $this->getFilePath($file),
                'timestamp' => $file->getMTime()
            ];

            if ($normalized['type'] === 'file') {
                $normalized['size'] = $file->getSize();
            }

            return $normalized;
        }
    }
500949
protected function checkFile(SplFileInfo $file, $force) {
        $scssPath = $file->getPathname();
        $scssMod = $file->getMTime();
        $scssName = preg_replace('/^.+(\/|\\\\)([^\/\\\\]+)$/', '\\2', $scssPath);

        // don't compile `_`-prefixed system files
        if (substr($scssName, 0, 1) === '_') {
            $this->sysMod = max($this->sysMod, $scssMod);
            return;
        }

        $cssPath = preg_replace('/(\.|\/|\\\\)scss($|\/|\\\\)/', '\\1css\\2', $scssPath);
        $cssMod = is_file($cssPath) ? filemtime($cssPath) : 0;
        $this->oldestMod = min($this->oldestMod, $cssMod);

        $isModified = $scssMod - $cssMod > 0 ? true : false;

        if ($isModified || $force) {
            $this->generateCss($scssPath, $cssPath);
        }
        
        // Possibly imported mixin/sys file changed, update all CSS files
        if (!$force && $this->sysMod > $this->oldestMod) {
            $this->checkFiles(true);
            $this->oldestMod = $this->sysMod;
        }        
    }
469907
public function checkEnoughStorageSpaceLeft(Workspace $workspace, \SplFileInfo $file)
    {
        $workspaceManager = $this->container->get('claroline.manager.workspace_manager');
        $workspaceDir = $workspaceManager->getStorageDirectory($workspace);
        $fileSize = filesize($file);
        $allowedMaxSize = $this->ut->getRealFileSize($workspace->getMaxStorageSize());
        $currentStorage = $this->ut->getRealFileSize($workspaceManager->getUsedStorage($workspace));

        return ($currentStorage + $fileSize > $allowedMaxSize) ? false: true;
    }
187875
function isExecutable(string $file): bool {
    $fileInfo = new \SplFileInfo($file);
    if (!$fileInfo->isFile()) return false;
    if ($fileInfo->isExecutable()) return true;
    return static::isWindows() ? $this->checkFileExtension($fileInfo) : $this->checkFilePermissions($fileInfo);
  }
470931
protected function load(SplFileInfo $file)
    {
        $path = $file->getPathName();

        if (!isset($this->cache['contents'][$path])) {
            $data    = $this->decoder->decode($file->getContents(), static::getFormat($file));
            $context = ['file' => $file, 'data' => $data];

            if (is_array($data)) {
                foreach ($this->handlers as $property => $handler) {
                    if ($handler->isSupported($data)) {
                        $value = isset($data[$property]) ? $data[$property] : null;
                        $data[$property] = $handler->handle($value, $context);
                    }
                }
            }

            $this->cache['contents'][$path] = $data;
        }

        return $this->cache['contents'][$path];
    }
1306358
protected function hasExtension(SplFileInfo $file): bool
    {
        if ($this->extension === null) {
            return true;
        }

        return strtolower($file->getExtension()) === strtolower($this->extension);
    }
286568
private function resolve(SplFileInfo $file): Closure
    {
        return function(IServerRequest $request, IResponse $response, callable $next) use ($file)
        {
            return $this->container->call(import($file->getRealPath()),
            [
                'request' => $request,
                'response' => $response,
                'next' => $next,
                'config' => $this->config
            ]);
        };
    }
117117
public function fileExt($file, $rule)
    {
        if (!($file instanceof SplFileObject)) {
            return false;
        }

        return $this->checkExt($file, $rule);
    }
664181
protected function parse(\SplFileInfo $file): array
    {
        $config = require_once $file->getRealPath();

        if (!is_array($config)) {
            throw new ConfigurationParseException('Invalid configuration file');
        }

        return $config;
    }
581053
public function clean(SplFileInfo $file)
    {
        $name = $file->getFilename();
        if ($file->isFile()) {
            $name = pathinfo($name, PATHINFO_FILENAME);
        }

        $name = str_replace("\t\n\r\0\x0B", ' ', $name); // remove control characters
        $name = str_replace('_', ' ', $name);

        $name = preg_replace('/\[[^\[\]]*\]/', ' ', $name); // remove [...]
        $name = preg_replace('/\([^\(\)]*\)/', ' ', $name); // remove (...)

        // remove all file meta data
        $reg = sprintf('/[ .,](?:%s)[ .,]/i', implode('|', $this->meta));
        while (preg_match($reg, $name.' ')) {
            $name = preg_replace($reg, ' ', $name.' ');
        }

        $name = str_replace('  ', ' ', $name); // remove double spaces
        $name = trim($name, ' .,-');

        return $name;
    }
898893
public function getFileContents(\SplFileInfo $file)
    {
        if ($file->getExtension() === 'php') {
            $content = include $file->getPathname();
            return $content;
        }

        $level = error_reporting(0);
        $content = file_get_contents($file->getPathname());
        error_reporting($level);
        if (false === $content) {
            $error = error_get_last();
            throw new \RuntimeException($error['message']);
        }
        return $content;
    }