You are here

public static function Helper::determineBaseFile in Drupal 7

Determines base file that can be accessed using the regular file system. For e.g. "phar:///home/user/bundle.phar/content.txt" that would result into "/home/user/bundle.phar".

Parameters

string $path:

Return value

string|null

2 calls to Helper::determineBaseFile()
PharExtensionInterceptor::baseFileContainsPharExtension in misc/typo3/drupal-security/PharExtensionInterceptor.php
Determines if a path has a .phar extension or invoked execution.
PharInvocationResolver::resolveBaseName in misc/typo3/phar-stream-wrapper/src/Resolver/PharInvocationResolver.php

File

misc/typo3/phar-stream-wrapper/src/Helper.php, line 49

Class

Helper
Helper provides low-level tools on file name resolving. However it does not (and should not) maintain any runtime state information. In order to resolve Phar archive paths according resolvers have to be used.

Namespace

TYPO3\PharStreamWrapper

Code

public static function determineBaseFile($path) {
  $parts = explode('/', static::normalizePath($path));
  while (count($parts)) {
    $currentPath = implode('/', $parts);
    if (@is_file($currentPath) && realpath($currentPath) !== false) {
      return $currentPath;
    }
    array_pop($parts);
  }
  return null;
}