Resolve a plugin file to its full path.

@param string $file The theme file to find.
@throws RuntimeException when plugins are missing.
@return string The expanded path
9256
protected function _expandPlugin($file)
    {
        preg_match(self::PLUGIN_PATTERN, $file, $matches);
        if (empty($matches[1]) || empty($matches[2])) {
            throw new RuntimeException('Missing required parameters');
        }
        if (!CorePlugin::isLoaded($matches[1])) {
            throw new RuntimeException($matches[1] . ' is not a loaded plugin.');
        }
        $path = CorePlugin::path($matches[1]);

        return $path . 'webroot' . DS . $matches[2];
    }
944219
protected function _expandTheme($file)
    {
        $file = preg_replace(self::THEME_PATTERN, '', $file);

        return CorePlugin::path($this->theme) . 'webroot' . DS . $file;
    }
938880
protected function resolveFilePath($path)
    {
        //Returns, if it's a remote file
        if (is_url($path)) {
            return $path;
        }

        //If it a relative path, it can be a file from a plugin or a file
        //  relative to `APP/webroot/img/`
        if (!Folder::isAbsolute($path)) {
            $pluginSplit = pluginSplit($path);

            //Note that using `pluginSplit()` is not sufficient, because
            //  `$path` may still contain a dot
            $path = WWW_ROOT . 'img' . DS . $path;
            if (!empty($pluginSplit[0]) && in_array($pluginSplit[0], CorePlugin::loaded())) {
                $path = CorePlugin::path($pluginSplit[0]) . 'webroot' . DS . 'img' . DS . $pluginSplit[1];
            }
        }

        is_readable_or_fail($path);

        return $path;
    }
895588
public function compileFile($file, $full = true)
    {
        if (!$file instanceof File\File) {
            $file = $this->finder()->find($file);
            if (!$file) {
                throw new Exception\RuntimeException(sprintf(
                    "Couldn't find asset file '%s'",
                    $file
                ));
            }
        }
        
        if ($full) {
            return $this->compileFileFull($file);
        } else {
            return $this->compileFileBody($file);
        }
    }
11928
public function get($file)
    {
        $basepath = $this->config['basepath'];
        $suffix = $this->config['suffix'];
        $target = "$basepath/$file{$suffix}";

        if (!is_readable($target)) {
            throw new \Exception(t("No such file content: @FILENAME", ["@FILENAME" => $target]));
        }

        $filter  = $this->config['textfilter'];
        $content = file_get_contents($target);
        $content = $this->di->textFilter->doFilter($content, $filter);

        return $content;
    }
497023
public static function getExtension($file){

		$file = trim($file);
		$extension = strtolower(substr(strrchr($file, '.'), 1));

		if($extension == $file){

			return '';
		}
		else{

			return $extension;
		}
	}
191212
public function load($file)
    {
        if (!is_file($file)) {
            if (!$found = $this->findFile($file)) {
                $paths = array_values(iterator_to_array(clone $this->paths));

                $paths = implode(" / ", $paths);

                throw new \RuntimeException(sprintf('Language file: %s not found. Paths in queue: %s', $file, $paths));
            }
        } else {
            $found = $file;
        }

        return file_get_contents($found);
    }
357428
public function shortPath($file)
    {
        $shortPath = str_replace(ROOT, null, $file);
        $shortPath = str_replace('..' . DIRECTORY_SEPARATOR, '', $shortPath);
        $shortPath = str_replace(DIRECTORY_SEPARATOR, '/', $shortPath);

        return str_replace('//', DIRECTORY_SEPARATOR, $shortPath);
    }
184358
public function path($file = '', $theme = null)
    {
        if (is_null($theme)) {
            $theme = $this->getCurrent();
        }

        $theme = $this->format($theme);

        return base_path("themes/{$theme}/{$file}");
    }
1133719
public function ensureDefaultFormat($file)
	{
		if ( ! pathinfo($file, PATHINFO_EXTENSION))
		{
			$file .= '.'.$this->defaultFormat;
		}

		return empty($this->configFolder) ? $file : $this->configFolder.DIRECTORY_SEPARATOR.$file;
	}
277821
public function toFile($file)
	{
		$minified = $this->minify();

		// Create dir
		$dir = dirname($file);

		if (!is_dir($dir))
		{
			if (is_file($dir))
			{
				throw new \RuntimeException(sprintf('Path: %s is already a file.', $dir));
			}

			if (!@mkdir($dir, 0755, true) && !is_dir($dir))
			{
				throw new \RuntimeException(sprintf('Auto create dir: %s fail.', $dir));
			}
		}

		file_put_contents($file, $minified);

		return $this;
	}
241214
public function chmod($file, $mode)
    {
        if (!chmod($this->alias->resolve($file), $mode)) {
            throw new RuntimeException(['chmod `:file` file to `:mode` mode failed: :last_error_message', 'file' => $file, 'mode' => $mode]);
        }
    }
490172
public function resolveClassname($file)
    {

        $splFile = new SplFileInfo($file);
        $parts   = explode('_', $splFile->getFilename());
        $strings = [];
        foreach ($parts as $part) {
            if (is_numeric($part)) {
                continue;
            }
            array_push($strings, $part);
        }
        $class = Str::studly(implode('_', $strings));
        return new $class;
    }
88180
public static function for_file($file)
    {
        if (!$file || (is_string($file) && !file_exists($file))) {
            return null;
        }

        // Ensure we have a File instance to work with
        if (is_string($file)) {
            /** @var File $fileObject */
            $fileObject = File::create();
            $fileObject->setFromLocalFile($file);
            $file = $fileObject;
        }

        $extension = $file->getExtension();
        $mime = $file->getMimeType();

        foreach (self::get_extractor_classes() as $className) {
            $extractor = self::get_extractor($className);

            // Skip unavailable extractors
            if (!$extractor->isAvailable()) {
                continue;
            }

            // Check extension
            if ($extension && $extractor->supportsExtension($extension)) {
                return $extractor;
            }

            // Check mime
            if ($mime && $extractor->supportsMime($mime)) {
                return $extractor;
            }
        }
    }
643996
public function get_asset_url( $file ) {
		if ( $this->get_wp_filesystem()->is_file( $file ) ) {
			$file = str_replace( plugin_dir_path( $this->plugin_file ), '', $file );
		}

		return plugins_url( $file, $this->plugin_file );
	}
503324
public function basePath($file = '')
    {
        $basePath = dirname($_SERVER['PHP_SELF']);
        if ($basePath != '/') {
            $basePath .= '/';
        }

        if (! empty($file)) {
            $basePath.= ltrim($file, '/');
        }

        return $basePath;
    }
316604
protected function looksLikePlugin($file)
    {
        if (! $file || ! $this->filesystem->isFile($file) || ! $this->filesystem->isReadable($file)) {
            return false;
        }

        $chunk = str_replace("\r", "\n", file_get_contents($file, false, null, 0, 8192));

        return preg_match('/^[ \t\/*#@]*Plugin Name:(.*)$/mi', $chunk, $match) && $match[1];
    }