Function to remove absolute path

@param string $dir
@param string $relative_path
@return string
973343
private static function iterateProcessPathInnerHelper(string $dir, string $relative_path) {
		if ($relative_path == '') {
			return $dir;
		} else {
			$dir = trim2($dir, '^' . $relative_path, '');
			$dir = ltrim($dir, DIRECTORY_SEPARATOR);
			return $dir;
		}
	}
703790
static function clear_dir($dir, $delete_me = false)
    {
        $dir = self::makeVirtualDir($dir, false);
        $result = false;
        if (is_file($dir)){
            $result = @unlink($dir);
        }else
        if (is_dir($dir)){
            $scan = glob(rtrim($dir, '/').'/*');
            foreach ($scan as $path){
                self::clear_dir($path, true);
            }
            $result = $delete_me?@rmdir($dir):true;
        }
        self::deleteVirtualDir($dir);
        return $result;
    }
163745
public function pathToClass($relativePath)
    {
        if (strpos($relativePath, '/') !== false) {
            $relativePath = dirname($relativePath).'/'.basename($relativePath, '.php');
        } else {
            $relativePath = basename($relativePath, '.php');
        }

        return str_replace('/', '\\', $relativePath);
    }
888073
public static function deleteDir($dir)
    {
        $d = dir($dir);
        while (false !== ($entry = $d->read())) {
            if ($entry == '.' || $entry == '..') {
                continue;
            }

            $currele = $d->path . '/' . $entry;
            if (is_dir($currele)) {
                if (self::isEmpty($currele)) {
                    rmdir($currele);
                } else {
                    self::deleteDir($currele);
                }
            } else {
                unlink($currele);
            }
        }
        $d->close();

        rmdir($dir);
        return true;
    }
1140670
def remove_path_dirname(path):
        
        dir_to_remove = os.path.dirname(path)
        if not os.listdir(dir_to_remove):
            shutil.rmtree(dir_to_remove)
        else:
            if len(os.listdir(dir_to_remove)) == 1:
                if os.listdir(dir_to_remove)[0].startswith('.'):
                    shutil.rmtree(dir_to_remove)
1174012
public static function delete(string $dir, bool $isIncludeSelf = false):bool
    {
        if (!is_dir($dir)) {
            return false;
        }
        $handle = opendir($dir);
        while ($file = readdir($handle)) {
            if ($file != '.' && $file != '..') {
                $realPath = realpath($dir . '/' . $file);
                if (is_dir($realPath)) {
                    static::delete($realPath, true);
                } else {
                    unlink($realPath);
                }
            }
        }
        closedir($handle);
        if ($isIncludeSelf) {
            return rmdir($dir);
        }
        return true;
    }
171475
def relative_path_from(root_path, path)
      project_path = Pathname.new(path)
      return project_path if project_path.relative?
      project_path.relative_path_from(root_path)
    end
726436
@CheckForNull
  public String relativePath(Path dir, Path file) {
    Path baseDir = dir.normalize();
    Path path = file.normalize();
    if (!path.startsWith(baseDir)) {
      return null;
    }
    try {
      Path relativized = baseDir.relativize(path);
      return FilenameUtils.separatorsToUnix(relativized.toString());
    } catch (IllegalArgumentException e) {
      return null;
    }
  }
301488
def _absolute_path(path, relative_to=None):
    '''
    
    '''

    if path and os.path.isabs(path):
        return path
    if path and relative_to is not None:
        _abspath = os.path.join(relative_to, path)
        if os.path.isfile(_abspath):
            log.debug(
                'Relative path \'%s\' converted to existing absolute path '
                '\'%s\'', path, _abspath
            )
            return _abspath
    return path
540798
function _deleteDir(path) {
  if (fs.existsSync(path)) {
    var subpaths = fs.readdirSync(path);
    subpaths.forEach(function(subpath) {
      var curPath = path + '/' + subpath;
      if (fs.lstatSync(curPath).isDirectory()) {
        _deleteDir(curPath);
      } else {
        fs.unlinkSync(curPath);
      }
    });
    fs.rmdirSync(path);
  }
}
232743
static function deleteDirectory($dirPath)
    {
        $dirPath = realpath($dirPath);
        if (!is_dir($dirPath)) return false;
        if (!static::cleanDirectory($dirPath)) return false;
        return rmdir(realpath($dirPath));
    }
18078
public function getURL(Dir $relativeDir = NULL) {
    if (!isset($relativeDir)) $relativeDir = new Dir('.'.DIRECTORY_SEPARATOR);
    
    $rel = clone $this;
    $rel->makeRelativeTo($relativeDir);
    $pa = $rel->getPathArray();
    unset($pa[0]);
    
    return '/'.implode('/',array_map('rawurlencode',$pa)); 
  }
347088
protected function removeChildDirecotries(string $dir = null)
    {
        if (empty($dir)) {
            $dir = $this->cacheDir;
        }

        $success = true;
        $objects = new GlobIterator($dir);

        foreach ($objects as $object) {
            if (!is_dir("$dir/$object") && is_link("$dir/$object")) {
                $success = $this->recursiveRemove("$dir/$object") && rmdir($dir) && $success;
            }
        }

        return $success;
    }
946359
function recursiveRemoveDir($dir)
    {
        if (is_link($dir)) {
            @unlink($dir);
        } else if (is_dir($dir)) {
            $files = array_diff(@scandir($dir), array('.', '..'));
            foreach ($files as $file) {
                (is_dir("$dir/$file")) ? $this->recursiveRemoveDir("$dir/$file") : @unlink("$dir/$file");
            }
        }
        return @rmdir($dir);
    }
1202103
public function removeInDir($dirPath, $removeWithDir = false)
    {
        $fileList = $this->getFileList($dirPath, false);

        $result = true;
        if (is_array($fileList)) {
            foreach ($fileList as $file) {
                $fullPath = Utils\Util::concatPath($dirPath, $file);
                if (is_dir($fullPath)) {
                    $result &= $this->removeInDir($fullPath, true);
                } else if (file_exists($fullPath)) {
                    $result &= unlink($fullPath);
                }
            }
        }

        if ($removeWithDir && $this->isDirEmpty($dirPath)) {
            $result &= $this->rmdir($dirPath);
        }

        return (bool) $result;
    }
793416
def delete_dir_rec(path: Path):
    
    if not path.exists() or not path.is_dir():
        return
    for sub in path.iterdir():
        if sub.is_dir():
            delete_dir_rec(sub)
        else:
            sub.unlink()
    path.rmdir()
869456
function _remove_dir($dir)
    {
        $dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $dir));

        $temp = &$this->dirs;
        foreach ($dirs as $dir) {
            if ($dir == end($dirs)) {
                unset($temp[$dir]);
                return true;
            }
            if (!isset($temp[$dir])) {
                return false;
            }
            $temp = &$temp[$dir];
        }
    }