Get absolute project directory path
@param string $tail
@return string
@throws \Exception
495613
public function getProjectRoot(string $tail = ''): string
    {
        if(empty($this->root) || !is_dir($this->root)) {
            throw new \Exception("Invalid root dir or not set yet!");
        }

        return realpath($this->root) . $tail;
    }
678098
public function getCurrentBranch($projectRoot)
    {
        $result = Shell::execute('(cd {projectRoot}; {binPath} branch)', [
            '{binPath}' => $this->binPath,
            '{projectRoot}' => $projectRoot,
        ]);
        foreach ($result->outputLines as $line) {
            if (($pos = stripos($line, '* ')) === 0) {
                return trim(substr($line, $pos + 2));
            }
        }
        throw new Exception('Unable to detect current GIT branch: ' . $result->toString());
    }
984106
public static function getUrlPathFromFilePath($filePath, $relativeToRootUrl = false) {
		$dir = $filePath;
		$rootPath = ROOT_PATH;
		
		if (strpos($dir, ROOT_PATH) === 0) {
			$dirUrl = ROOT_URL.substr(ROOT_PATH, strlen(__DIR__)+1);
		} else {
			// The directory URL is below the ROOT_URL. Let's try to find it (not 100% success rate)
			$rootPaths = explode(DIRECTORY_SEPARATOR, trim($rootPath, DIRECTORY_SEPARATOR));
			$thisDirs = explode(DIRECTORY_SEPARATOR, trim($dir, DIRECTORY_SEPARATOR));
		
			for ($i=0; $i<count($rootPaths); $i++) {
				if ($rootPaths[$i] != $thisDirs[$i]) {
					break;
				}
			}
		
			$nbSkip = count($rootPaths) - $i;
			$urls = explode('/', trim(ROOT_URL, '/'));
		
			if ($nbSkip > count($urls)) {
				throw new Exception('The directory "'.$dir.'" is almost certainly out of reach from the web.');
			}
		
			$dirUrls = array();
			for ($j=0; $j < count($urls)- $nbSkip; $j++) {
				$dirUrls[] = $urls[$j];
			}
			for ($k = $i; $k<count($thisDirs); $k++) {
				$dirUrls[] = $thisDirs[$k];
			}
			$dirUrl = '/'.implode('/', $dirUrls);
			
			if ($relativeToRootUrl) {
				$dirUrl = ltrim(str_repeat('/..', count($urls)).$dirUrl, '/');
			}
		}
		return $dirUrl;
	}
1357176
private function realPath($absolutePath): string
    {
        $finalParts = [];
        $currentIndex = -1;

        $absolutePath = $this->normalizeSlashes($absolutePath);
        foreach (explode('/', $absolutePath) as $pathPart) {
            if ('..' === $pathPart) {
                // we need to remove the previous entry
                if (-1 === $currentIndex) {
                    throw new \Exception(sprintf('Problem making path relative - is the path "%s" absolute?', $absolutePath));
                }

                unset($finalParts[$currentIndex]);
                --$currentIndex;

                continue;
            }

            $finalParts[] = $pathPart;
            ++$currentIndex;
        }

        $finalPath = implode('/', $finalParts);
        // Normalize: // => /
        // Normalize: /./ => /
        $finalPath = str_replace(['//', '/./'], '/', $finalPath);

        return $finalPath;
    }
998395
public static function getUriFromFile($absolutepath)
	{
		if (self::isWindowsOS())
		{
			$result = "file:///".$absolutepath;

			$search = "\\";
			$replace = "/";

			$result =str_replace($search, $replace, $result);
		}
		else
		{
			$result = "file://".$absolutepath;
		}
		return $result;

	}
762002
public function getAbsolutePath()
    {
        if (!$this->isAbsolute()) {
            $filepath = stream_resolve_include_path($this->getPathname());
        } else {
            $filepath = realpath($this->getPathname());
        }
        return $filepath;
    }
1007959
protected function getSearchPath()
    {
        if (!isset($this->config['mp3']['searchPath'])) {
            throw new \Exception(
                $this->translate->translate(
                    'searchPath is not currently set',
                    'mp3'
                )
            );
        }

        return $this->config['mp3']['searchPath'];
    }
960450
public function getDirectory($name, $ext)
	{
		if ('' === $name = '/' . trim($name, '/.') . '/')
			return true;

		$type = $this->getTypeForExt($ext);

		foreach ($this->paths as $path)
		{
			$prefixes = isset($path['prefixes']) ? $path['prefixes'] : array();
			$prefix = isset($prefixes[$type]) ? $prefixes[$type] . '/' : '';
			
			foreach ($path['directories'] as $directory)
			{
				if (file_exists($directory) && is_dir($directory))
					return $directory;
			}
		}
		
		throw new Exception\DirectoryNotFound($name);
	}
238872
protected function getDataDirectoryPath() {
    $data_dir = $this->getEnvironment()->getDataDirectory();
    $config = $this->getConfiguration();
    return str_replace('{branch}', $config->getBranch(), $data_dir);
  }
657839
public function getCurrentBranch($projectRoot)
    {
        $result = Shell::execute('(cd {projectRoot}; {binPath} branch)', [
            '{binPath}' => $this->binPath,
            '{projectRoot}' => $projectRoot,
        ]);
        return $result->outputLines[0];
    }
76285
function abspath( $path = false ) {
		if ( ! $path )
			$path = ABSPATH;
		$folder = $this->find_folder( $path );

		// Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
		if ( ! $folder && $this->is_dir('/wp-includes') )
			$folder = '/';
		return $folder;
	}
1093478
function getScriptPath()
    {
        $fileName = $this->stack->pop();
        if ($this->baseDir) {
            return $this->baseDir . \DIRECTORY_SEPARATOR . $fileName;
        } else {
            return (string)$fileName;
        }
    }
1033739
public function getClassPath(string $fullyQualifiedClassName) : string
    {
        $parts = explode('\\', $fullyQualifiedClassName);

        /**
         * If the root namespace does have a directory (eg Project\MyClass lives in src/Project/MyClass.php),
         * then we do include it in the path
         * If the root namespace does not have a directory (eg Project\MyClass lives in src/MyClass.php),
         * then we do not include it in the path (ie don't use "Project" in the path)
         *
         * Note:  This is mainly for backwards-compatibility with the directory structure for v1.0.* of the
         * skeleton project.  This is hacky, but it works.
         */
        if (file_exists(realpath($this->psr4RootPath . '/' . $parts[0]))) {
            $path = array_slice($parts, 0, -1);
        } else {
            $path = array_slice($parts, 1, -1);
        }

        $path[] = end($parts) . '.php';
        array_unshift($path, $this->psr4RootPath);

        return implode(DIRECTORY_SEPARATOR, $path);
    }
242572
protected function getAppBasePath()
    {
        $path = dirname($_SERVER['SCRIPT_FILENAME']);

        return (is_link($path)) ? dirname(readlink($path)) : dirname($path);
    }
48543
public function getBaseTmpDir()
    {
        $folders = explode(DIRECTORY_SEPARATOR, $this->getRootDir());
        $foldersCount = count($folders);

        /**
         * Base Path
         */
        $projectDir = '';
        if (true === isset($folders[$foldersCount - 2])) {
            $projectDir = $folders[$foldersCount - 2];
        }

        $tempDirPath = FileUtility::getUserBasedCachedDir(sprintf('%s-%s', $projectDir, $this->getEnvironment()));
        FileUtility::mkdir($tempDirPath);

        return $tempDirPath;
    }
232779
protected function getProjectRootPath(): string
    {
        try {
            return Config::getProjectRootDirectory();
        } catch (\Exception $e) {
            throw new DoctrineStaticMetaException(
                'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
                $e->getCode(),
                $e
            );
        }
    }
123863
public static function getPathFromUrl($url) {
        if (substr($url, 0, strlen(ROOT_URL)) != ROOT_URL) {
            throw new common_Exception($url.' does not lie within the tao instalation path');
        }
        $subUrl = substr($url, strlen(ROOT_URL));
        $parts = array();
        foreach (explode('/', $subUrl) as $directory) {
            $parts[] = urldecode($directory);
        }
        $path = ROOT_PATH.implode(DIRECTORY_SEPARATOR, $parts);
        if (self::securityCheck($path)) {
            return $path;
        } else {
            throw new common_Exception($url.' is not secure');
        }
    }