Resolves file path.
Give the absolute path of a path

@param string $filename

@return string
504737
public function path($filename)
    {
        if (preg_match('~^' . $this->base_directory . '~', $filename)) {
            return $filename;
        }

        return rtrim($this->base_directory, '/') . '/' . ltrim($filename, '/');
    }
132343
public function getFile($filename)
    {
        $filename = $this->outDir.DIRECTORY_SEPARATOR.$filename;
        $this->mkdir(dirname($filename));
        if (is_file($filename) && $this->backup) {
            @rename($filename, sprintf('%s.bak', $filename));
        }

        return $filename;
    }
1272167
public function getFilePath($fileName = null)
    {
        if ($fileName === null) {
            $fileName = $this->fileName;
        }

        return $this->theme->getPath().'/'.$this->dirName.'/'.$fileName;
    }
109193
protected function find_handler_path($filename) {
	$filename = strtolower($filename);
	
	if (preg_match('{[^a-z0-9/_-]}', $filename)) {
		return false;
	}
	
	$base_path = \alsvanzelf\fem\ROOT_DIR_APP.$this->handler_base_path.'/';
	$full_path = $base_path.$filename.'.php';
	if (file_exists($full_path) == false) {
		return false;
	}
	
	// sanity check to prevent escaping outside the base dir
	if (strpos($full_path, $base_path) !== 0) {
		return false;
	}
	
	return $full_path;
}
1248311
public function getFilePath($fileName = null)
    {
        if ($fileName === null) {
            $fileName = $this->fileName;
        }

        $component = $this->component;
        $path = $component->getPath().'/'.$fileName;

        /*
         * Check the shared "/partials" directory for the partial
         */
        if (!File::isFile($path)) {
            $sharedDir = dirname($component->getPath()).'/partials';
            $sharedPath = $sharedDir.'/'.$fileName;
            if (File::isFile($sharedPath)) {
                return $sharedPath;
            }
        }

        return $path;
    }
832732
public function resolveFile($fileName, $rootDir = null)
    {
        if ($rootDir === null) {
            return $this->fileUtils->resolveFile($this->basedir, $fileName);
        } else {
            return $this->fileUtils->resolveFile($rootDir, $fileName);
        }
    }
461977
protected function resolve_file_path($file = null)
    {
        if (is_null($file)) {
            $file = $this->args->file;
        }

        if (file_exists($file)) {
            return $file;
        }

        $dirname  = dirname($file);
        $filename = basename($file);
        $relpath  = $dirname ? "/$dirname" : '';
        $path     = getcwd() . "$relpath/$filename";

        /**
         * realpath will return false if path does not exist
         */
        return realpath($path) ?: str_replace('/./', '/', $path);
    }
354525
public function get($filename)
    {
        if ($this->exists($filename) && $this->isFile($filename)) {
            return file_get_contents($filename);
        }

        throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
    }
1120110
protected function resolvePath($name)
    {
        try {
            $path = RelativePath::fromString($name);
        } catch (NonRelativePathException $exception) {
            $path = AbsolutePath::fromString($name);
        }
        $resultPath = $this->rootPath->resolve($path);

        return $resultPath->normalize()->string();
    }
1319357
public function assetPath($fileName, array $options = [])
    {
        if ($this->isRelativePath($fileName)) {
            if (substr($fileName, 0, 1) == '/') {
                $path = $fileName;
            } else {
                $path = '';
                
                if ($this->config['serve_static_assets']) {
                    $path = $this->getStaticAssetUrl($fileName);
                }
                
                if (!$path) {
                    $file = $this->getService('assets')->findFile($fileName);
                    if (!$file) {
                        $path = $this->defaultPath($fileName, $options);
                    } else {
                        $path = $file->url();
                    }
                }
            }
            
            return $this->properPath($path, $options);
        } else {
            return $fileName;
        }
    }
1205321
public function getFullPath($filename = null)
    {
        if (!$filename) {
            $filename = $this->Filename;
        }
        return DMS::inst()->getStoragePath() . DIRECTORY_SEPARATOR . $this->Folder . DIRECTORY_SEPARATOR . $filename;
    }
505603
private function getShortPath($filename)
    {
        if (getcwd() === dirname($filename)) {
            return basename($filename);
        }
        $homeDir = Filesystem::getHomeDirectory();
        if (strpos($filename, $homeDir) === 0) {
            return str_replace($homeDir, '~', $filename);
        }

        return $filename;
    }
342433
protected function getFileName (string $fileName)
    {
        if (!$fileName && filter_var ($fileName, FILTER_VALIDATE_URL) === false) {
            return null;
        }

        $explodeFileURL = explode ('/', $fileName);
        $fileName       = end ($explodeFileURL);

        return sanitizeString (pathinfo ($fileName, PATHINFO_FILENAME)) . '.' . pathinfo ($fileName, PATHINFO_EXTENSION);
    }
1226970
private function findFileInPath($filename, $path)
    {
        $path = $this->absolutizePath($path);
        if (!file_exists($path)) {
            $this->fail("Directory does not exist: $path");
        }

        $files = Finder::create()->files()->name($filename)->in($path);
        if ($files->count() === 0) {
            return false;
        }

        foreach ($files as $file) {
            return $file->getRealPath();
        }
    }
519875
public static function path($filename)
    {
        if ($filename[0] != "/") {
            $filename = static::$path . "/" . $filename;
        }

        if (substr($filename, -5) != ".json") {
            $filename .= ".json";
        }

        $path = pathinfo($filename, PATHINFO_DIRNAME);

        # Ensure the cache directory exists
        if (!is_dir($path)) {
            if (!mkdir($path, 0777, true)) {
                throw new \Exception("Unable to create cache directory (" . $path . ")");
            }
        }

        # Ensure directory is writable
        if (!is_writable($path)) {
            if (!chmod($path, 0777)) {
                throw new \Exception("Cache directory (" . $path . ") is not writable");
            }
        }

        return $filename;
    }
10262
public function isFile($filename)
    {
        $absolutePath = $this->parser->absoluteFilePath($filename);

        return file_exists($absolutePath) && is_file($absolutePath) ? $absolutePath : null;
    }
26959
public function findPath($filename)
    {
        if (!isset($this->_paths[$filename])) {
            foreach ($this->_search_paths as $path) {
                $file = $path.'/'.$filename;
                if ($this->findFile($file)) {
                    $this->_paths[$filename] = $file;
                    return $file;
                }
            }

            $this->_paths[$filename] = false;
        }

        return $this->_paths[$filename];
    }