Determine the root folder absolute system path

@param string $root
@return string
499503
protected function findRoot($root)
    {
        // Empty root will set the path to assets
        if (!$root) {
            throw new \InvalidArgumentException("Missing argument for root path");
        }

        // Substitute leading ./ with BASE_PATH
        if (strpos($root, './') === 0) {
            return BASE_PATH . substr($root, 1);
        }

        // Substitute leading ./ with parent of BASE_PATH, in case storage is outside of the webroot.
        if (strpos($root, '../') === 0) {
            return dirname(BASE_PATH) . substr($root, 2);
        }

        return $root;
    }
317272
private static function buildPath($root, array $parts)
    {
        if ($parts === []) {
            return $root === '' ? '.' : $root;
        }

        return $root . implode(DIRECTORY_SEPARATOR, $parts);
    }
1253804
public function getRootDirectory()
    {
        if(isset($this->rootDirectory) == false) {
            $this->rootDirectory = $this->locateRootDirectory();
        }
        return $this->rootDirectory;
    }
575831
private function determineGitRoot($path)
    {
        // @codingStandardsIgnoreStart
        while (\strlen($path) > 1) {
            // @codingStandardsIgnoreEnd
            if (\is_dir($path . DIRECTORY_SEPARATOR . '.git')) {
                return $path;
            }

            $path = \dirname($path);
        }

        throw new \RuntimeException('Could not determine git root, starting from ' . \func_get_arg(0));
    }
341304
protected function ensureDirectory($root)
	{
		if (!\is_dir($root)) {
			$umask = \umask(0);
			@\mkdir($root, $this->permissionMap['dir']['public'], true);
			\umask($umask);

			if (!\is_dir($root)) {
				throw new FileSystemException('Impossible to create the root directory "' . $root . '".');
			}
		}
	}
1317303
public function path()
    {
        $dirname = $this->dirname();

        if ($this->parent instanceof Root) { //at root

            return $dirname.$this->basename();
        }

        return sprintf('%s/%s', $dirname, $this->basename());

    }
258728
public function getRootPath()
  {
    $folder = WebApp::getPageFolder() . $this->code;
    if (StringTools::right($folder, 1) != '/') {
      $folder .= '/';
    }
    return $folder;
  }
723264
public static function getRootDirectoryPath($additional_path = null)
    {
        $root = \dirname(\dirname(\dirname(__DIR__)));

        return \is_string($additional_path) && ! empty($additional_path)
            ? $root . DIRECTORY_SEPARATOR . ltrim((string) $additional_path, ' \\/')
            : $root;
    }
1224279
private function getDocument($root = null)
    {
        return $this->document !== null ? $this->document : $this->document = $this->createDocument($root);
    }
268943
private function rooted($path)
	{
		if (substr($path, 0, strlen(PATH_ROOT)) == PATH_ROOT)
		{
			$path = 'ROOT' . substr($path, strlen(PATH_ROOT));
		}
		return $path;
	}
1071699
private function getPath($path)
    {
        return $this->root .
            ltrim(
                preg_replace(
                    sprintf('|%s{2,}|', preg_quote(DIRECTORY_SEPARATOR)),
                    DIRECTORY_SEPARATOR,
                    $path
                ),
                DIRECTORY_SEPARATOR
            );
    }
1080980
protected function path($file)
    {
        return $this->root .
            str_replace('.', '/', $file) .
            $this->extensions[$this->type];
    }
689924
function dir($root = false, $current = false)
    {
        $dir = $this->uri($current);
        if ($root){
            return DIR.trim($dir,'/').'/';
        }else{
            return $dir.'/';
        }
    }
949964
public static function rootPath($directory) {
        $num = count(explode("/", $directory));
        $path = "";
        for ($i = 0; $i < $num; $i++)
            $path = self::join("..", $path);
        return $path;
    }
105367
private function completePath(string $resource): string
    {
        if (substr($resource, 0, strlen((string) $this->rootpath)) == $this->rootpath) {
            return $resource;
        }

        return $this->rootpath
                . DIRECTORY_SEPARATOR . 'src'
                . DIRECTORY_SEPARATOR . 'main'
                . DIRECTORY_SEPARATOR . 'resources'
                . DIRECTORY_SEPARATOR . $resource;
    }
1199898
protected function root()
    {
        if(isset($_GET['_framework_url_']))
        {
            $url = $_GET['_framework_url_'];
        }
        else return false;

        $parts = explode('/', $url);
        $count = count($parts)-2;
        //
        $path = $parts > 1 ? '../' : '';

        for ($i=0; $i <$count; $i++) 
        { 
            $path .= '../';
        }

        \Vinala\Kernel\Foundation\Application::$path = $path;
        return $path;
    }
277535
public function find($base)
    {
        $base = rtrim($base, '/');
        // Special case for a base path of /, eg. a chroot environment
        if ($base === '') {
            $base = '/';
        }

        $paths = array(array($base, 0));
        $found = array();

        $fileCallback = $this->getOption('file_callback');
        $dirCallback  = $this->getOption('dir_callback');

        while ($path = array_shift($paths)) {
            list($path, $depth) = $path;

            foreach (scandir($path) as $basename) {
                if ($basename == '.' || $basename == '..') {
                    continue;
                }

                if (is_dir("$path/$basename")) {
                    if (!$this->acceptDir($basename, "$path/$basename", $depth + 1)) {
                        continue;
                    }

                    if ($dirCallback) {
                        call_user_func(
                            $dirCallback,
                            $basename,
                            "$path/$basename",
                            $depth + 1
                        );
                    }

                    $paths[] = array("$path/$basename", $depth + 1);
                } else {
                    if (!$this->acceptFile($basename, "$path/$basename", $depth)) {
                        continue;
                    }

                    if ($fileCallback) {
                        call_user_func(
                            $fileCallback,
                            $basename,
                            "$path/$basename",
                            $depth
                        );
                    }

                    $found[] = "$path/$basename";
                }
            }
        }

        return $found;
    }