Returns the database table name to use for the specified file.

For files detected as cache files the cache table is returned, if not
the generic table is returned.

@param string $filePath
@return string The database table name
197419
protected function dbTable( $filePath )
     {
         if ( $this->metaDataTableCache == $this->metaDataTable )
             return $this->metaDataTable;

         if ( strpos( $filePath, $this->cacheDir ) !== false && strpos( $filePath, $this->storageDir ) === false )
         {
             return $this->metaDataTableCache;
         }

         return $this->metaDataTable;
    }
593385
static protected function nameTrunk( $filePath, $scope )
    {
        switch ( $scope )
        {
            case 'viewcache':
            {
                $fileName = basename( $filePath );
                $nameTrunk = dirname( $filePath ) . '/' . substr( $fileName, 0, strpos( $fileName, '-' ) + 1 );
            } break;

            case 'template-block':
            {
                $templateBlockCacheDir = eZTemplateCacheBlock::templateBlockCacheDir();
                $templateBlockPath = str_replace( $templateBlockCacheDir, '', $filePath );
                if ( strstr( $templateBlockPath, 'subtree/' ) !== false )
                {
                    // 6 = strlen( 'cache/' );
                    $len = strlen( $templateBlockCacheDir ) + strpos( $templateBlockPath, 'cache/' ) + 6;
                    $nameTrunk = substr( $filePath, 0, $len  );
                }
                else
                {
                    $nameTrunk = $filePath;
                }
            } break;

            default:
            {
                $nameTrunk = $filePath;
            }
        }
        return $nameTrunk;
    }
975290
protected function getCacheFilePath()
    {
        $hash = md5($this->filePath);
        $result = storage_path().'/cms/cache/';
        $result .= substr($hash, 0, 2).'/';
        $result .= substr($hash, 2, 2).'/';
        $result .= basename($this->filePath);
        $result .= '.php';

        return $result;
    }
968570
protected function get_file_content(string $filepath) : String {
        $content = file_get_contents($filepath);
        if ($content === false) {
            throw new \moodle_exception('cannotopenfile', 'error', '', $filepath);
        }
        return $content;
    }
417466
protected function getFileRelativePath($filePath)
    {
        $commonParts = array();

        // replace window \ to work with /
        $rootDir = (false !== strpos($this->rootDir, '\\')) ? str_replace('\\', '/', $this->rootDir) : $this->rootDir;

        $antiSlash = false;
        if (false !== strpos($filePath, '\\')) {
            $filePath = str_replace('\\', '/', $filePath);
            $antiSlash = true;
        }

        $rootDirParts = explode('/', $rootDir);
        $filePathParts = explode('/', $filePath);

        $i = 0;
        while ($i < count($rootDirParts)) {
            if (isset($rootDirParts[$i], $filePathParts[$i]) && $rootDirParts[$i] == $filePathParts[$i]) {
                $commonParts[] = $rootDirParts[$i];
            }
            $i++;
        }

        $filePath = str_replace(implode('/', $commonParts).'/', '', $filePath);

        $nbCommonParts = count($commonParts);
        $nbRootParts = count($rootDirParts);

        for ($i = $nbCommonParts; $i < $nbRootParts; $i++) {
            $filePath = '../'.$filePath;
        }

        return $antiSlash ? str_replace('/', '\\', $filePath) : $filePath;
    }
824144
public static function getClassName($filePath)
    {
        $className = preg_replace('/\.php$/i', '', $filePath);
        $className = preg_replace('/^(application|custom)(\/|\\\)/i', '', $className);
        $className = '\\'.static::toFormat($className, '\\');

        return $className;
    }
1261836
public static String getFileName(String filePath) {
       int separatorIndex = filePath.lastIndexOf(separator);
       return separatorIndex < 0 ? filePath : filePath.substring(separatorIndex + 1,
    		   filePath.length());
   }
760285
protected function getLockPath(FilePath $filePath)
    {
        $name = $filePath->getName();
        $relativeLockPath = $filePath->getParentPath()->appendFile('.' . $name . '.lock');

        return $relativeLockPath;
    }
1100047
public static function firstLine($filepath)
    {
        if (file_exists($filepath)) {
            $cacheRes = fopen($filepath, 'rb');
            $firstLine = fgets($cacheRes);
            fclose($cacheRes);

            return $firstLine;
        }

        return null;
    }
37023
protected function getMethodObject(string $filePath, string $methodName)
    {
        $statements = $this->parseFile($filePath);
        if (empty($statements)) {
            return null;
        }
        $method = $this->getFunction($methodName, $statements);
        if (empty($method)) {
            return null;
        }

        return $method;
    }
280184
protected function getProperty(string $filePath, string $keyName)
    {
        $statements = $this->parseFile($filePath);
        if (empty($statements)) {
            return null;
        }

        return $this->getPropertyRecursive($keyName, $statements);
    }
357617
public function getProjectPath(string $filePath): string
    {
        $rootPath = $this->getRootApplicationDirectoryPathByFilePath($filePath);

        $path = rtrim($rootPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
        $path .= implode(DIRECTORY_SEPARATOR, [
            'src',
            'Pyz',
            'Zed',
        ]);

        return rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
    }
619165
public static function parse(string $filePath): FilePathInterface
    {
        if (!self::myFilePathParse(
            DIRECTORY_SEPARATOR,
            $filePath,
            function ($p, $d, &$e) {
                return self::myPartValidator($p, $d, $e);
            },
            null,
            $isAbsolute,
            $aboveBaseLevel,
            $drive,
            $directoryParts,
            $filename,
            $error)
        ) {
            throw new FilePathInvalidArgumentException('File path "' . $filePath . '" is invalid: ' . $error);
        }

        return new self($isAbsolute, $aboveBaseLevel, $drive, $directoryParts, $filename);
    }
802292
private function getFilePath($filePath = null)
    {
        $filePath = $filePath ?? $this->filePath ?? null;

        if (null === $filePath) {
            throw NoFilePathGivenException::import();
        }

        return $filePath;
    }
1184752
private function readSqlFile($filePath)
    {
        if (!file_exists(Configuration::projectDir() . $filePath)) {
            throw new ModuleConfigException(
                __CLASS__,
                "\nFile with dump doesn't exist.\n"
                . "Please, check path for sql file: "
                . $filePath
            );
        }

        $sql = file_get_contents(Configuration::projectDir() . $filePath);

        // remove C-style comments (except MySQL directives)
        $sql = preg_replace('%/\*(?!!\d+).*?\*/%s', '', $sql);

        return $sql;
    }
39418
public function readFile($filePath)
    {
        try {
            $file = fopen($filePath, 'r');
            $content = fread($file, filesize($filePath));
            fclose($file);
            return $content;
        } catch (\Exception $e) {
            return '';
        }
    }
1362256
private function restoreFile($filePath)
    {
        try {
            for ($i = 0; $i < $this->_config->getHostRetryLimit(); ++$i) {
                /* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */
                @fopen($filePath, 'x');

                if (false === $fileData = file_get_contents($filePath)) {
                    return null;
                }
                return $fileData;
            }
        } catch (\Exception $e) {
            return null;
        }

        return null;
    }