Find the plugin containing a given file
@param $file string filename
@return plugin name or boolean False
483793
public static function memberOf($file, $exclude='plugins')
    {
        $file = realpath($file);
        $sep = DIRECTORY_SEPARATOR;

        $dirs = explode($sep, $file);
        for($i=0;$i<count($dirs);$i++) {
            if ($dirs[$i] == $exclude && isset($dirs[$i+1])) {
                return $dirs[$i+1];
            }
        }

        return false;
    }
567288
public function locateFile($file)
    {
        $components = $this->parseResource($file);
        if ($components['path']) {
            $path = dirname($components['path']) . '/public/';

            return $path . $components['file'];
        } else {
            return $components['file'];
        }
    }
968466
protected function parse_file($file = null) {
        if (is_null($file)) {
            $file = $this->file;
        }

        if (empty($this->file_data)) {
            $this->load_data($file);
        }

        return !empty($this->file_data) ? $this->parse_string() : false;
    }
1116177
protected function find($directory)
    {
        if ($iterator = parent::find($directory)) {
            foreach ($iterator as $file) {
                if (is_file($file) && is_readable($file) && $contents = file_get_contents($file)) {
                    if (preg_match($this->packageNamePattern, basename($file))) {
                        $plugin = (object) null;
                        $plugin->name = implode('_v', array_slice(explode('_v', basename($file, '.txt')), 0, -1));
                        $this->plugin[] = $plugin;
                        $this->package[] = $contents;
                    }
                }
            }
        }

        return !empty($this->plugin);
    }
525085
public function getFileClassNamespace($file)
    {
        $filenameBlock = explode(DIRECTORY_SEPARATOR, $file);
        $filename = explode('.', end($filenameBlock), 2);
        $filename = reset($filename);

        preg_match('/\snamespace\s+(.+?);/s', file_get_contents($file), $match);

        return    is_array($match) && isset($match[1])
                ? $match[1] . '\\' . $filename
                : false;
    }
761297
protected function _findFile($file)
    {
        foreach ($this->_settings['paths'] as $path) {
            $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
            if (file_exists($path . $file)) {
                return $path . $file;
            }
        }
        return $file;
    }
870652
public function findByFile($file)
    {
        if ($file instanceof File) {
            $file = $file->getFileID();
        }

        return $this->findBy([
            'file_id' => $file
        ]);
    }
800296
public static function get($file = false) {

        if ($file && self::isFile($file)) {

            return file_get_contents($file);
        }

        return false;
    }
196243
public function getContent($file)
    {
        $this->fileInfo = GeneralUtility::makeInstance(Fileinfo::class);
        $this->fileInfo->setFile($file);

        // get PDF informations
        if (!$pdfInfo = $this->getPdfInfo($file)) {
            return false;
        }

        // proceed only of there are any pages found
        if ((int)$pdfInfo['pages'] && $this->isAppArraySet) {
            // create the tempfile which will contain the content
            $tempFileName = GeneralUtility::tempnam('pdf_files-Indexer');

            // Delete if exists, just to be safe.
            @unlink($tempFileName);

            // generate and execute the pdftotext commandline tool
            $fileEscaped = CommandUtility::escapeShellArgument($file);
            $cmd = "{$this->app['pdftotext']} -enc UTF-8 -q $fileEscaped $tempFileName";

            CommandUtility::exec($cmd);

            // check if the tempFile was successfully created
            if (@is_file($tempFileName)) {
                $content = GeneralUtility::getUrl($tempFileName);
                unlink($tempFileName);
            } else {
                $errorMessage = 'Content for file ' . $file . ' could not be extracted. Maybe it is encrypted?';
                $this->pObj->logger->warning($errorMessage);
                $this->addError($errorMessage);

                // return empty string if no content was found
                $content = '';
            }

            return $this->removeEndJunk($content);
        } else {
            return false;
        }
    }
1133284
protected function getFileRecord($file)
    {
        $result = null;
        $segment = implode('/', [DIRNAME_GEOLOCATION, $this->geolocator->getGeolocatorHandle(), $file]);
        $fileLocator = $this->app->make(FileLocator::class);
        /* @var FileLocator $fileLocator */
        $package = $this->geolocator->getGeolocatorPackage();
        if ($package !== null) {
            $fileLocator->addPackageLocation($package->getPackageHandle());
        }

        return $fileLocator->getRecord($segment);
    }
812788
public static function find($paths, $file)
    {
        // Force to array
        if (!is_array($paths) && !($paths instanceof \Iterator))
        {
            settype($paths, 'array');
        }

        // Start looping through the path set
        foreach ($paths as $path)
        {
            // Get the path to the file
            $fullname = $path . '/' . $file;

            // Is the path based on a stream?
            if (strpos($path, '://') === false)
            {
                // Not a stream, so do a realpath() to avoid directory
                // traversal attempts on the local file system.

                $pathFile = new \SplFileInfo($path);
                $fullnameFile = new \SplFileInfo($fullname);

                $path = $pathFile->getPathInfo()->getPathname();
                $fullname = $fullnameFile->getPathInfo()->getPathname();

                if ($path !== false) {
                    $path .= DIRECTORY_SEPARATOR . $pathFile->getFilename();
                }

                if ($fullname !== false) {
                    $fullname .= DIRECTORY_SEPARATOR . $fullnameFile->getFilename();
                }
            }

            /*
             * The substr() check added to make sure that the realpath()
             * results in a directory registered so that
             * non-registered directories are not accessible via directory
             * traversal attempts.
             */
            if (file_exists($fullname) && substr($fullname, 0, strlen($path)) == $path)
            {
                return $fullname;
            }
        }

        // Could not find the file in the set of paths
        return false;
    }
632028
private function findFile($file) {
        $filePath = MODULES_DIR . DS . self::$currentRoute['module'] . DS . 'Views' . DS . $file . '.php';
        if (!file_exists($filePath)) {
            $filePath = BASE_DIR . DS . 'base' . DS . 'views' . DS . $file . '.php';
            if (!file_exists($filePath)) {
                throw new \Exception(_message(ExceptionMessages::VIEW_FILE_NOT_FOUND, $file));
            }
        }

        return $filePath;
    }
783150
public function findFile($file, $ext = '')
    {
        $paths = clone $this->getPaths();

        $file = str_replace('.', '/', $file);

        $ext = $ext ? '.' . trim($ext, '.') : '';

        foreach ($paths as $path) {
            $filePath = $path . '/' . $file . $ext;

            if (is_file($filePath)) {
                return realpath($filePath);
            }
        }

        return null;
    }
1098968
public function getFileContent($file)
    {
        // we can continue only when given file is really file and not a directory
        if ($this->fileInfo->getIsFile()) {
            $className = 'TeaminmediasPluswerk\KeSearch\Indexer\Filetypes\\' . ucfirst($this->fileInfo->getExtension());

            // check if class exists
            if (class_exists($className)) {
                // make instance
                $fileObj = GeneralUtility::makeInstance($className, $this->pObj);

                // check if new object has interface implemented
                if ($fileObj instanceof FileIndexerInterface) {
                    // Do the check if a file has already been indexed at this early point in order
                    // to skip the time expensive "get content" process which includes calls to external tools
                    // fetch the file content directly from the index
                    $fileContent = $this->getFileContentFromIndex($this->getUniqueHashForFile());

                    // if there's no matching index entry, we execute the  "get file content" method of our new object
                    if (!$fileContent) {
                        $fileContent = $fileObj->getContent($file);
                        $this->addError($fileObj->getErrors());
                    }

                    // remove line breaks from content in order to identify
                    // additional content (which will have trailing linebreaks)
                    $fileContent = str_replace("\n", ' ', $fileContent);

                    return $fileContent;
                } else {
                    return false;
                }
            } else {
                // if no indexer for this type of file exists, we do a fallback:
                // we return an empty content. Doing this at least the FAL metadata
                // can be indexed. So this makes only sense when using FAL.
                if ($this->pObj->indexerConfig['fal_storage'] > 0) {
                    return '';
                } else {
                    $errorMessage = 'No indexer for this type of file. (class ' . $className . ' does not exist).';
                    $this->pObj->logger->error($errorMessage);
                    $this->addError($errorMessage);
                    return false;
                }
            }
        } else {
            $errorMessage = $file . ' is not a file.';
            $this->pObj->logger->error($errorMessage);
            $this->addError($errorMessage);
            return false;
        }
    }
120936
public function readConfig($file = 'config.php')
    {
        $orig_file = $file;

        if (strpos($file, '.php') != strlen($file) - 4) {
            $file .= '.php';
        }

        if (strpos($file, '/') === false) {
            $file = getcwd().'/'.$this->config_location.'/'.$file;
        }

        if (file_exists($file)) {
            // some tricky thing to make config be read in some cases it could not in simple way
            unset($config);

            $config = &$this->config;
            $this->config_files_loaded[] = $file;
            include $file;

            unset($config);

            return true;
        }

        return false;
    }
674050
public function findFile($file, $ext = '')
    {
        $ext = $ext ?: $this->config->get('extension', 'mustache');

        return parent::findFile($file, $ext);
    }
1251984
protected function loadConfigFile($file)
    {
        $path = $this->getConfigPath() . '/' . $file;

        if (file_exists($path)) {
            $config = include $path;
            return is_array($config) ? $config : null;
        }

        return null;
    }