Identify current plugin.

@param path $pwd Optional. Path to working directory.
@return mixed The current plugin's name or false.
485922
public static function plugin($pwd = null) {
		if (empty($pwd)) {
			$pwd = self::path();
		}

		$plugins = CakePlugin::loaded();
		if (array_keys(self::$_plugins) != $plugins) {
			self::$_plugins = array();
			foreach ($plugins as $plugin) {
				self::$_plugins[$plugin] = CakePlugin::path($plugin);
			}
		}

		foreach (self::$_plugins as $plugin => $path) {
			if (false !== strpos($pwd, $path)) {
				return $plugin;
			}
		}

		return false;
	}
277300
public static function get_instance( $path ) {
		$path = \wp_normalize_path( $path );
		if ( ! isset( self::$instances[ $path ] ) ) {
			self::$instances[ $path ] = new self( $path );
		}
		return self::$instances[ $path ];
	}
647592
public static function GetDirContent($path)
    {
        $files = array();
        $directory = opendir($path);

        while(($file = readdir($directory)) !== false)
        {
            $full_path = $path . "/" . $file;

            if(is_file($full_path))
            {
                $files[] = $full_path;
            }
            elseif($file != "." && $file != ".." && is_dir($full_path))
            {
                $files[] = $full_path;
                $files = array_merge($files, self::GetDirContent($full_path));
            }
        }

        closedir($directory);

        return $files;
    }
1199067
public function getModuleByPath($path)
    {
        // Ensure path exists
        $path = realpath($path);
        if (!$path) {
            return null;
        }

        /** @var Module $rootModule */
        $rootModule = null;

        // Find based on loaded modules
        $modules = ModuleLoader::inst()->getManifest()->getModules();
        foreach ($modules as $module) {
            // Check if path is in module
            if (stripos($path, realpath($module->getPath())) !== 0) {
                continue;
            }

            // If this is the root module, keep looking in case there is a more specific module later
            if (empty($module->getRelativePath())) {
                $rootModule = $module;
            } else {
                return $module;
            }
        }

        // Fall back to top level module
        return $rootModule;
    }
1249474
public static function findRepositoryRoot($path)
    {
        return FileSystem::bubble($path, function($p) {
            $gitDir = $p.'/'.'.git';
            return file_exists($gitDir) && is_dir($gitDir);
        });
    }
39784
protected function findAbsolutePath($path)
    {
        if (is_file($path) || is_dir($path)) {
            return realpath($path);
        }

        if (null === $this->basePath) {
            return false;
        }

        if (is_file($this->basePath . DIRECTORY_SEPARATOR . $path)
               || is_dir($this->basePath . DIRECTORY_SEPARATOR . $path)) {
            return realpath($this->basePath . DIRECTORY_SEPARATOR . $path);
        }

        return false;
    }
508806
function get_plugin_type($dirpath) {
        global $CFG;
        $dirpath = $CFG->dirroot.$dirpath;
        // Reverse order so that we get subplugin matches.
        $plugintypes = array_reverse(core_component::get_plugin_types());
        foreach ($plugintypes as $plugintype => $pluginbasedir) {
            if (substr($dirpath, 0, strlen($pluginbasedir)) == $pluginbasedir) {
                return $plugintype;
            }
        }
        return null;
    }
698364
protected static function getFilesFoundButNotExpected()
    {
        $files = \Piwik\Manifest::$files;
        $pluginsInManifest = self::getPluginsFoundInManifest();

        $filesFoundButNotExpected = array();

        foreach (self::getPathsToInvestigate() as $file) {
            if (is_dir($file)) {
                continue;
            }
            $file = substr($file, strlen(PIWIK_DOCUMENT_ROOT)); // remove piwik path to match format in manifest.inc.php
            $file = ltrim($file, "\\/");

            if (self::isFileFromPluginNotInManifest($file, $pluginsInManifest)) {
                continue;
            }
            if (self::isFileNotInManifestButExpectedAnyway($file)) {
                continue;
            }
            if (self::isFileFromDirectoryThatShouldBeDeleted($file)) {
                // we already report the directory as "Directory to delete" so no need to repeat the instruction for each file
                continue;
            }

            if (!isset($files[$file])) {
                $filesFoundButNotExpected[] = $file;
            }
        }

        return $filesFoundButNotExpected;
    }
965284
public function inPath($path = '', $reverse = false)
    {
        $dir = Folder::slashTerm($path);
        $current = Folder::slashTerm($this->pwd());

        if (!$reverse) {
            $return = preg_match('/^(.*)' . preg_quote($dir, '/') . '(.*)/', $current);
        } else {
            $return = preg_match('/^(.*)' . preg_quote($current, '/') . '(.*)/', $dir);
        }

        return (bool) $return;
    }
878869
static function GetFileSystemEntryType($path)
    {
        if (is_file($path))
            return FileSystemEntryType::File();
        else if (is_link($path))
            return FileSystemEntryType::Link();
        else if (is_dir($path))
            return FileSystemEntryType::Folder();
        else
            throw new Exceptions\PathNotFoundException("Path $path not found");
    }
718992
public function cd($path)
    {
        $path = $this->realpath($path);
        if ($path !== false && is_dir($path)) {
            return $this->path = $path;
        }

        return false;
    }
613906
function register_dependency( $path ){
	
		// register as not having been processed yet
		if( ! isset($this->dependencies[$path]) ){
			$this->dependencies[$path] = 0;
		}
		
		// return path suitable for use in include directive
		// consulting include path settings avoids hard coded paths 
		if( isset($this->incpaths) ){
			$path = PLUG_VIRTUAL_DIR . PLUGTool::map_deployment_virtual( $path );
			return relpath( $this->cwd, $path, $this->incpaths );
		}

		// else we must map this path to the target host with a full path
		$base = $this->conf_consts['PLUG_VIRTUAL_DIR'];
		return $base . PLUGTool::map_deployment_virtual( $path );
	}
1362617
private function truepath($path)
    {
        // whether $path is unix or not
        $unipath = ('' === $path) || ($path{0} !== '/');

        // attempts to detect if path is relative in which case, add cwd
        if (strpos($path, ':') === false && $unipath) {
            $path = $this->_currentDir . DIRECTORY_SEPARATOR . $path;
        }

        // resolve path parts (single dot, double dot and double delimiters)
        $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
        $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
        $absolutes = array();
        foreach ($parts as $part) {
            if ('.' === $part) {
                continue;
            }
            if ('..' === $part) {
                array_pop($absolutes);
            } else {
                $absolutes[] = $part;
            }
        }

        $path = implode(DIRECTORY_SEPARATOR, $absolutes);
        // resolve any symlinks
        if (file_exists($path) && linkinfo($path) > 0) {
            $path = readlink($path);
        }
        // put initial separator that could have been lost
        $path = !$unipath ? '/' . $path : $path;

        return $path;
    }
319279
protected function isDirectory($path)
    {
        $location = $this->applyPathPrefix($path);

        if (empty($location)) {
            return true;
        }

        try {
            $file = $this->share->stat($location);
        } catch (NotFoundException $e) {
            return false;
        }

        return $file->isDirectory();
    }
742630
public static function getResourcePath($path)
    {
        if (self::$importPaths === null) {
            self::$importPaths = self::explodeIncludePath();
        }

        $path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $path);

        foreach (self::$importPaths as $prefix) {
            $testPath = $prefix . DIRECTORY_SEPARATOR . $path;
            if (file_exists($testPath)) {
                return $testPath;
            }
        }

        // Check for the property phing.home
        $homeDir = self::getProperty(self::PHING_HOME);
        if ($homeDir) {
            $testPath = $homeDir . DIRECTORY_SEPARATOR . $path;
            if (file_exists($testPath)) {
                return $testPath;
            }
        }

        // Check for the phing home of phar archive
        if (strpos(self::$importPaths[0], 'phar://') === 0) {
            $testPath = self::$importPaths[0] . '/../' . $path;
            if (file_exists($testPath)) {
                return $testPath;
            }
        }

        // Do one additional check based on path of current file (Phing.php)
        $maybeHomeDir = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
        $testPath = $maybeHomeDir . DIRECTORY_SEPARATOR . $path;
        if (file_exists($testPath)) {
            return $testPath;
        }

        return null;
    }
206615
public static function get($path)
    {
        $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
        if (!isset(self::$fileTypes[$ext])) {
            return false;
        }
        return self::$fileTypes[$ext];
    }
132218
protected function _pluginPath($pluginName)
    {
        if (Plugin::isLoaded($pluginName)) {
            return Plugin::path($pluginName);
        }

        return current(App::path('Plugin')) . $pluginName . DIRECTORY_SEPARATOR;
    }