Get base path for FTP.

@param  string  $path

@return string
344909
protected function basePath(string $path): string
    {
        // This set of preg_match would filter ftp' user is not accessing
        // exact path as path('public'), in most shared hosting ftp' user
        // would only gain access to it's /home/username directory.
        if (\preg_match('/^\/(home)\/([a-zA-Z0-9]+)\/(.*)$/', $path, $matches)) {
            $path = '/'.\ltrim($matches[3], '/');
        }

        return $path;
    }
904030
protected function realpath(string $path): string
    {
        if ($path === '') {
            return $this->baseDir;
        }

        if ($path[0] === '/' || (!empty($path[1]) && $path[1] === ':')) {
            return $path;
        }

        return $this->baseDir . '/' . $path;
    }
857711
public static function getPath($path = '')
    {
        $path = ltrim($path, '/\\');
        $path = sprintf('%s%s%s', self::$applicationRoot, DIRECTORY_SEPARATOR, $path);
        $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
        return $path;
    }
642781
private function fileRelativePath($path)
    {
        $path = $this->fileWebpath($path);
        // @todo This wont work for files not located on the current server...
        $path = str_replace_first(env('APP_URL'), '', $path);
        $path = str_replace(' ', '%20', $path);

        return $path;
    }
48815
public function asset($path)
    {
        if (null !== $this->basePath) {
            return $this->request->getUri()->getBaseUrl().'/'.trim($this->basePath, '/').'/'.$path;
        }

        return $this->request->getUri()->getBaseUrl().'/'.$path;
    }
654507
public static function getRelativePath($path, $base = GRAV_ROOT)
    {
        if ($base) {
            $base = preg_replace('![\\\/]+!', '/', $base);
            $path = preg_replace('![\\\/]+!', '/', $path);
            if (strpos($path, $base) === 0) {
                $path = ltrim(substr($path, strlen($base)), '/');
            }
        }

        return $path;
    }
532977
protected function makeAbsolutePath($path)
    {
        $path = $this->serverUrlHelper->__invoke($this->basePathHelper->__invoke($path));
        return $path;
    }
927834
protected function _path($path) {
		return $this->rootName.($path == $this->root ? '' : $this->separator.$this->_relpath($path));
	}
1113812
private function getPath($path)
    {
        $uri = parse_url($path);

        $stream = $this->getStreamByPathScheme($path);
        if ($stream instanceof StreamInterface) {
            foreach ($stream->getPaths() as $streamDomain => $streamPath) {
                if ($streamDomain === $uri['host']) {
                    $realPath = $this->getRealPath($uri, $streamPath);
                    if (strpos($realPath, $streamPath) === 0) {
                        return $realPath;
                    }
                }
            }
        }
    }
1050516
public static function realpath($path) {
    if (file_exists($path)) {
      return str_replace("\\", "/", realpath($path));
    }
    $path = str_replace("\\", "/", $path);
    $parts = array_filter(explode("/", $path), 'strlen');
    $absolutes = [];
    foreach ($parts as $part) {
      if ('.' == $part) {
        continue;
      }
      if ('..' == $part) {
        array_pop($absolutes);
      }
      else {
        $absolutes[] = $part;
      }
    }
    $result = implode("/", $absolutes);
    if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
      $result = '/'.$result;
    }
    return $result;
  }
1367034
public function baseUrl($path) {

        $url = '';

        if (\strpos($path, ':')===false) {

            /*
            if ($this->registry['base_port'] != '80') {
                $url .= $this->registry['site_url'];
            }
            */

            $url .= $this->registry['base_url'].'/'.\ltrim($path, '/');

        } else {
            $url = $this->pathToUrl($path);
        }

        return $url;
    }
387895
protected function buildUrl($path)
    {
        $path = str_replace('%2F', '/', $path);
        $path = str_replace(' ', '%20', $path);

        return rtrim($this->base, '/') . '/' . $path;
    }
1165500
protected function getPath($path)
	{
		$rootPath = $this->option('path');

		return $rootPath.'/'.strtolower($this->getTheme()).'/' . $path;
	}
710353
public static function getFileBaseNameWithoutExt($path)
    {
        $baseName = pathinfo($path,PATHINFO_BASENAME);
        $extName= self::getFileExtName($path);
        $pos=strrpos($baseName, $extName);
        if($pos>0){
            $baseName=substr($baseName, 0,$pos-1);
        }
        return $baseName;
    }
782474
public function base($path = null)
    {
        if ($path !== null) {
            $path = trim($path, '/');
            $this->base = $path ? '/' . $path : null;
            $this->baseRoute = [];
        }

        return $this->base;
    }
1349284
public function getRealpath($path)
    {
        $path   = $this->applyPathPrefix($path);
        $s3path = sprintf("s3://%s/%s", $this->getBucket(), $path);

        return $s3path;
    }
326677
public function buildsPath(string $path = ''): string
    {
        return $this->basePath('builds'.($path ? DIRECTORY_SEPARATOR.$path : $path));
    }