Return the relative path from parentDir to subDir.

@param  array $subDir
@param  array $parentDir
@return string
190844
public static function getSubPathOf(array $subDir, array $parentDir) : string
    {
        if (!self::isSubDirectoryOf($subDir, $parentDir)) {
            throw new \RuntimeException('Invalid sub directory');
        }

        $path = [];
        foreach (array_slice($subDir, count($parentDir)) as $dir) {
            $path[] = $dir;
        }
        return implode(DIRECTORY_SEPARATOR, $path);
    }
1310623
public function path(): string
    {
        if (null === $this->parentPath) {
            return $this->name;
        }

        return $this->parentPath . '/' . $this->name;
    }
1056914
public function getRelativePathToCurrentDirectoryParent()
    {
        if ($this->baseDir === $this->currentDir) {
            return DIRECTORY_SEPARATOR;
        }

        $path = realpath($this->currentDir . DIRECTORY_SEPARATOR . '..');

        return $this->getPathRelativeToBaseDir($path) ?: DIRECTORY_SEPARATOR;
    }
1320606
protected function getCacheFileURL($subdir, $safe_filename)
    {
        $path = $this->getCachePathFromWebRoot($subdir);

        return URL::getInstance()->absoluteUrl(sprintf("%s/%s", $path, $safe_filename), null, URL::PATH_TO_FILE, $this->cdnBaseUrl);
    }
257407
public function getRelativePath(File $base_dir) {
        return FileSystem::getFileSystem()->makePathRelative($this->file->getAbsoluteFile()->getParent(), $base_dir->getAbsolutePath()) . $this->file->getName();
    }
1200120
public function getAction($subdir, $name)
    {
        $file = $this->logDir.$subdir.DIRECTORY_SEPARATOR.$name.'.json';

        if (file_exists($file)) {
            return new Response(file_get_contents($file));
        }

        return new JsonResponse(['log' => 'no file found']);
    }
1087176
def is_subdir(child, parent):
    
    child_path = os.path.realpath(child)
    parent_path = os.path.realpath(parent)

    if len(child_path) < len(parent_path):
        return False

    for i in range(len(parent_path)):
        if parent_path[i] != child_path[i]:
            return False

    return True
495715
def _get_sub_dirs(parent):
    """"""
    return [child for child in os.listdir(parent) if os.path.isdir(os.path.join(parent, child))]
1170122
public function GetGenericTemplate($name, $subdir="")
    {
        if($subdir)
            $subdir = trim($subdir, "\\/") . "/";
        
        return $this->templates_path
            . $subdir
            . "{$name}.php"
        ;
    }
204887
public function GetPathForView($rootDir) {
        $path = "APP_ROOT_DIR" .
                $rootDir .
                ucfirst($this->controller->module()) .
                "/" .
                ucfirst($this->controller->action()) .
                self::VIEWFILEEXTENSION;
        return $path;
    }
747423
public static String getRootDirURI(File parentDir) {
        String pathAsString = parentDir.getAbsolutePath() + System.getProperty("file.separator") + Names.EKSTAZI_ROOT_DIR_NAME;
        return new File(pathAsString).toURI().toString();
    }
1256473
static function recursiveFindRelative( $baseDir, $subDir, $suffix )
    {
        $dir = $baseDir;
        if ( $subDir != "" )
        {
            if ( $dir != '' )
                $dir .= "/" . $subDir;
            else
                $dir .= $subDir;
        }

        if ( !is_dir( $dir ) )
        {
            return array();
        }

        $returnFiles = array();
        if ( $handle = @opendir( $dir ) )
        {
            while ( ( $file = readdir( $handle ) ) !== false )
            {
                if ( ( $file == "." ) || ( $file == ".." ) )
                {
                    continue;
                }
                if ( is_dir( $dir . '/' . $file ) )
                {
                    if ( $file[0] != "." )
                    {
                        $files = eZDir::recursiveFindRelative( $baseDir, $subDir . '/' . $file, $suffix );
                        $returnFiles = array_merge( $files, $returnFiles );
                    }
                }
                else
                {
                    if ( preg_match( "/$suffix$/", $file ) )
                        $returnFiles[] = $subDir . '/' . $file;
                }
            }
            @closedir( $handle );
        }
        return $returnFiles;
    }
1029325
protected function getFilePath($filename, $subDir = null)
    {
        $directories = presenter()->assets->getFilePaths();
        
        foreach ($directories as $directory) {

            /**
             * Try with sub directory
             * find from public directory first then resource directory
             */
            if (isset($subDir)) {
                $subDir = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $subDir);

                if (is_file($filePath = str_replace(PATH_RESOURCES, PATH_PUBLIC,
                        $directory) . $subDir . $filename)) {
                    return $filePath;
                    break;
                } elseif (is_file($filePath = str_replace(PATH_RESOURCES, PATH_PUBLIC . 'assets' . DIRECTORY_SEPARATOR,
                        $directory) . $subDir . $filename)) {
                    return $filePath;
                    break;
                } elseif (is_file($filePath = $directory . $subDir . $filename)) {
                    return $filePath;
                    break;
                }
            }

            /**
             * Try without sub directory
             * find from public directory first then resource directory
             */
            if (is_file($filePath = str_replace(PATH_RESOURCES, PATH_PUBLIC, $directory) . $filename)) {
                return $filePath;
                break;
            } elseif (is_file($filePath = str_replace(PATH_RESOURCES, PATH_PUBLIC . 'assets' . DIRECTORY_SEPARATOR,
                    $directory) . $filename)) {
                return $filePath;
                break;
            } elseif (is_file($filePath = $directory . $filename)) {
                return $filePath;
                break;
            }
        }

        return false;
    }
832055
def get_parent_dir(base_dir, level=1):
    ""
    while level > 0:
        base_dir = os.path.dirname(base_dir)
        level -= 1
    return base_dir
150508
public function getPath($separator=' > ', $includeNode=false)
    {
        $path = array();

        $ancestors = $this->getAncestors();
        if($ancestors)
        {
            foreach($ancestors as $ancestor)
            {
                $path[] = $ancestor->getNode()->__toString();
            }
        }

        if($includeNode)
        {
            $path[] = $this->getNode()->__toString();
        }

        return implode($separator, $path);
    }
1245871
public function getRealDir($path, $rootDir)
    {
        if (!is_string($path)) {
            return false;
        }

        if ($this->isRelativePath($path)) {
            return realpath($rootDir . DIRECTORY_SEPARATOR . dirname($path));
        }

        return realpath(dirname($path));
    }
929133
protected function get_parent_path($path) {
        if (!isset($this->parentcache[$path])) {
            $this->parentcache[$path] = progressive_parser::dirname($path);
            $this->parentcacheavailablesize--;
            if ($this->parentcacheavailablesize < 0) {
                // Older first is cheaper than LRU.  We use 10% as items are grouped together and the large quiz
                // restore from MDL-40585 used only 600 parent paths. This is an XML heirarchy, so common paths
                // are grouped near each other. eg; /question_bank/question_category/question/element. After keeping
                // question_bank paths in the cache when we move to another area and the question_bank cache is not
                // useful any longer.
                $this->parentcache = array_slice($this->parentcache, 200, null, true);
                $this->parentcacheavailablesize += 200;
            }
        }
        return $this->parentcache[$path];
    }