Returns the full path and filename, relative to the BaseURL
@param File|string $f
@return string
501437
public function getRelativeLinkFor($f)
    {
        $fn = is_object($f) ? $f->getFilename() : $f;
        return trim(str_replace($this->localPath, '', $fn), '/');
    }
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;
	}
78639
private function getFilePath()
    {
        $fullname = $this->fullName;
        $rootPath = Yii::getAlias('@webroot');

        if (substr($fullname, 0, 1) != '/') {
            $fullname = '/' . $fullname;
        }

        return $rootPath . $fullname;
    }
819071
protected function getFilePath(string $path): string
    {
        if (empty($path)) {
            $path = $this->fileName;
        }

        return $path;
    }
81206
protected function _getFileName($file)
    {
        $rename = [];
        foreach ($this->files as $value) {
            if ($value['source'] == '*') {
                if (!isset($rename['source'])) {
                    $rename           = $value;
                    $rename['source'] = $file;
                }
            }

            if ($value['source'] == $file) {
                $rename = $value;
                break;
            }
        }

        if (!isset($rename['source'])) {
            return $file;
        }

        if (!isset($rename['target']) || $rename['target'] == '*') {
            $rename['target'] = $rename['source'];
        }

        if (is_dir($rename['target'])) {
            $name = basename($rename['source']);
            $last = $rename['target'][strlen($rename['target']) - 1];
            if (($last != '/') && ($last != '\\')) {
                $rename['target'] .= DIRECTORY_SEPARATOR;
            }

            $rename['target'] .= $name;
        }

        if ($rename['randomize']) {
            $info = pathinfo($rename['target']);
            $newTarget = $info['dirname'] . DIRECTORY_SEPARATOR .
                $info['filename'] . uniqid('_');
            if (isset($info['extension'])) {
                $newTarget .= '.' . $info['extension'];
            }
            $rename['target'] = $newTarget;
        }

        return $rename;
    }
863272
private function path($file, array $options = []) {
        // get base and full paths
        $base = $this->Url->assetUrl($file, $options);
        $fullpath = preg_replace('/^' . preg_quote($this->request->getAttribute('webroot'), '/') . '/', '', urldecode($base));

        // do webroot path
        $webrootPath = Configure::read('App.wwwRoot') . str_replace('/', DS, $fullpath);
        if(file_exists($webrootPath))
            return $webrootPath;

        // do plugin webroot path
        $pluginFile = $this->_getPluginFile($fullpath);
        if($pluginFile !== null && file_exists($pluginFile))
            return $pluginFile;

        // not found?
        return false;
    }
344288
public function getImageWebPath(AbstractFile $file = null, $filter = null)
    {
        if (!$file) {
            return '';
        }

        $webPath = $this->getFileWebPath($file);

        return $filter ? $this->imagine->getBrowserPath($webPath, $filter) : $webPath;
    }
165094
public function real_to_url(string $file){

    foreach ( $this->repositories() as $i => $d ){
      if (
        // Repository's root path
        ($root = $this->get_root_path($d)) &&
        (strpos($file, $root) === 0)
      ){
				$res = $i;
        $bits = explode('/', substr($file, \strlen($root)));

        // MVC
        if ( !empty($d['tabs']) ){
          $tab_path = array_shift($bits);
          $fn = array_pop($bits);
          $ext = \bbn\str::file_ext($fn);
          $fn = \bbn\str::file_ext($fn, 1)[0];
          $res .= implode('/', $bits);
          foreach ( $d['tabs'] as $k => $t ){
            if (
              empty($t['fixed']) &&
              ($t['path'] === $tab_path . '/')
            ){
              $res .= "/$fn/$t[url]";
              break;
            }
          }
        }
        // Normal file
        else {
          $res .= implode('/', $bits);

        }
        return \bbn\str::parse_path($res);
      }
    }
    return false;
  }
465118
protected function getFullFileName($containerName, $fileName, $relativePath)
    {
        if ($relativePath === null) {
            $relativePath = '';
        } else {
            $relativePath = trim($relativePath, '/');
            $relativePath = $relativePath . '/';
        }

        return sprintf('%s/%s%s', $containerName, $relativePath, $fileName);
    }
1010430
protected function getFilePath(string $file, ?string $extension = null, ?string $suffix = null): string
	{
		if(strpos($file, '::') === false)
		{
			// No namespace so we'll just use the default path

			$path = $this->path;
		}
		else
		{
			// The file is namespaced so we'll use the namespace path

			[$namespace, $file] = explode('::', $file, 2);

			if(!isset($this->namespaces[$namespace]))
			{
				throw new RuntimeException(vsprintf('The [ %s ] namespace does not exist.', [$namespace]));
			}

			$path = $this->namespaces[$namespace];
		}

		// Append suffix to path if needed

		if($suffix !== null)
		{
			$path .= DIRECTORY_SEPARATOR . $suffix;
		}

		// Return full path to file

		return $path . DIRECTORY_SEPARATOR . str_replace('.', DIRECTORY_SEPARATOR, $file) . ($extension ?? $this->extension);
	}
49535
public static function getFileNameFromPath(string $path)
    {
        $split = explode('/', $path);
        $name = (string)end($split);

        return $name;
    }
831995
protected function getFullPathNameWithHash($fileInfo)
  {
    $path = $this->resourceDirFullPath;
    $path .= '/'.$fileInfo['hash'].'.'.$fileInfo['ordinal'].$this->extension;

    return $path;
  }
217807
public function getFilePath($file): string
    {
        if (null === ($fileObj = $this->container->get('huh.utils.file')->getFileFromUuid($file))) {
            return '';
        }

        return $fileObj->path;
    }
801835
public function getFullPath()
    {
        /** @var Uri $uri */
        $uri = $this->getUri();

        return rtrim($uri->getBasePath(), '/') . '/' . ltrim($uri->getPath(), '/');
    }
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;
    }
1039619
public function getPathFromUrl($url)
    {
        $basename = $this->storageUrl ? basename($this->storageUrl) : basename($this->storageDir);
        $basename && $url = preg_replace("/(.*$basename\/)/", '', $url);
        return $url;
    }
1220058
public function toUrl($file)
    {
        $dir = realpath('.');
        $url = str_replace($dir, '', $file);
        $url = str_replace('//', '/', $url);
        $url = str_replace('\\', '/', $url);
        return $this->getBasePath() . $url;
    }