Attempt to get the directory name from a path.

@param string $path

@return string
3020
protected function dirname($path)
    {
        if (is_file($path)) {
            return dirname($path);
        }

        if (is_dir($path)) {
            return rtrim($path, '/');
        }

        // no known file/dir, start making assumptions

        // ends in / = dir
        if (mb_substr($path, -1) === '/') {
            return rtrim($path, '/');
        }

        // has a dot in the name, likely a file
        if (preg_match('/.*\..*$/', basename($path)) !== 0) {
            return dirname($path);
        }

        // you're on your own here!
        return $path;
    }
87538
static public function urlToPath($path)
    {
        $path = parse_url($path);
        return $path === null ? null : str_replace('/', DIRECTORY_SEPARATOR, $path['path']);
    }
301692
protected function getNamespace($path)
    {
        return str_replace(" ", "", str_replace("/", "\\", ucwords(str_replace(
            '-',
            ' ',
            str_replace('/ ', '/', ucwords(str_replace('/', '/ ', $path)))
        ))));
    }
838105
public function hashName($path = null)
    {
        if ($path) {
            $path = rtrim($path, '/') . '/';
        }
        $hash = $this->hashName ?: $this->hashName = StringHelper::randomString(40);
        return $path . $hash . '.' . $this->getExtension();
    }
1202267
protected function _relpath($path) {
		return $path == $this->root ? '' : substr($path, strlen($this->root)+1);
	}
787325
public function getPath(string $path = ''): string
    {
        return $this->dirPath.($path ? DIRECTORY_SEPARATOR.$path : $path);
    }
1366518
protected function getMountPoint(/*# string */ $path)/*# : string */
    {
        while ($path !== '') {
            if (isset($this->filesystems[$path])) {
                return $path;
            }
            $path = substr($path, 0, strrpos($path, '/'));
        }
        return '/';
    }
1114817
public function getThemePath($path)
    {
        $path = pathinfo($this->themeDir.'/'.$path);
        $pathDirname = $path['dirname'];
        $pathBasename = $path['basename'];
        $pathFilename = $pathDirname.'/'.$pathBasename;

        if (!file_exists($pathFilename)) {
            return null;
        }

        return $pathFilename;
    }
500268
private function getImagePath($path)
    {
        if ($path && file_exists($this->filesystem->getRootDir() . $path)) {
            return $path;
        }

        return $this->noImagePath;
    }
808377
public static function getAbsolutePath(string $path): string
    {
        $parts = \preg_split('~[/\\\\]+~', $path, 0, \PREG_SPLIT_NO_EMPTY);
        $absolutes = [];
        foreach ($parts as $part) {
            if ('.' === $part) {
                continue;
            }
            if ('..' === $part) {
                \array_pop($absolutes);
            } else {
                $absolutes[] = $part;
            }
        }

        /**
         * Allows to dereference char
         */
        $__FILE__ = \preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__);// remove file protocols such as "phar://" etc.
        $prefix = $__FILE__[0] === \DIRECTORY_SEPARATOR ? \DIRECTORY_SEPARATOR : '';
        return $prefix . \implode(\DIRECTORY_SEPARATOR, $absolutes);
    }
520686
protected function get_pathfor($path = '') {
        $path = trim($path, '/') !== '' ? '/' . trim($path, '/') : '';
        return $this->connectionpoint->get_path() . '/' .
               'plugin_' . $this->plugintype . '_' .
               $this->pluginname . '_' . basename($this->connectionpoint->get_path()) . $path;
    }
1036928
protected function get_src_path( $path = '' ) {
        return rtrim( $this->get_path( $this->options->src_dir ), '/' ) .
            ( strlen( $path )  ? '/' . $path : '' );
    }
498031
private function getPath(string $path) : string
  {
    $path = str_replace('"', "", $path);
    $path = str_replace("'", "", $path);

    $views = self::$views;
    $file = explode('.', $path);

    foreach($file as $name) {
      if (is_dir($views . DIRECTORY_SEPARATOR . $name)) {
        $views = $views . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR;
      }
      else {
        $views = $views . (ends_with($views, '/') ? '' : '.') . $name;
      }
    }

    $parent = substr(self::$views, strrpos(self::$views, DIRECTORY_SEPARATOR) + 1);

    if (str_contains($views, $parent . '.')) {
      $views = str_replace($parent . '.', $parent . DIRECTORY_SEPARATOR, $views);
    }

    return str_replace(self::$views, '', $views);
  }
1001223
public function getAbsolutePath($path)
    {
        if (DIRECTORY_SEPARATOR === '\\') {
            if (preg_match('/^(?>[a-zA-Z]:\\\\|\\\\\\\\)/', $path) !== 1) {
                $path = $this->getRootDir() . $path;
            }
        } else {
            if ($path[0] !== '/') {
                $path = $this->getRootDir() . $path;
            }
        }
        return rtrim($path, '/\\') . '/';
    }
507601
public static function getFolder($path)
    {
        if (!is_dir($path)) return null;

        $path = rtrim($path, '/') . '/';

        $array = array('file' => array(), 'folder' => array());
        $dir_obj = opendir($path);

        while ($dir = readdir($dir_obj)) {
            if ($dir != '.' && $dir != '..') {
                $file = $path . $dir;
                if (is_dir($file)) {
                    $array['folder'][] = $dir;
                } elseif (is_file($file)) {
                    $array['file'][] = $dir;
                }

            }
        }
        closedir($dir_obj);
        return $array;

    }
876346
protected function getPackageName($path)
    {
        if (ends_with($path, '.zip')) {
            $path = dirname($path);
        }
        $manifest = new Manifest(new Filesystem(), $path);
        return $manifest->get('package');
    }
1144400
protected function splitPath($path)
    {
        $lastSlashPos = strrpos($path, '/');
        if (false === $lastSlashPos) {
            return array('dirname' => '', 'basename' => $path);
        }

        return array('dirname'  => substr($path, 0, $lastSlashPos),
                     'basename' => substr($path, $lastSlashPos + 1)
               );
    }