Get the relative path of an application

@param root the root to relativize against
@param path the path to relativize
@return the relative path
344589
public static String getRelativePathName(Path root, Path path) {
        Path relative = root.relativize(path);
        return Files.isDirectory(path) && !relative.toString().endsWith("/") ? String.format("%s/", relative.toString()) : relative.toString();
    }
257517
public static String getFolderPath(final String path) {

		String cleanedPath = clean(path);

		if (cleanedPath != null && cleanedPath.contains(PATH_SEP)) {

			return PATH_SEP + StringUtils.substringBeforeLast(cleanedPath, PATH_SEP);

		} else {

			return PATH_SEP;

		}
	}
1159703
public static URI getRelativePath(final URI relativePath) {
        final StringTokenizer tokenizer = new StringTokenizer(relativePath.toString(), URI_SEPARATOR);
        final StringBuilder buffer = new StringBuilder();
        if (tokenizer.countTokens() == 1) {
            return null;
        } else {
            while(tokenizer.countTokens() > 1) {
                tokenizer.nextToken();
                buffer.append("..");
                buffer.append(URI_SEPARATOR);
            }
            return toURI(buffer.toString());
        }
    }
228416
public String canonicalOrAbsolutePath(String path) {

        try {
            return canonicalPath(path);
        } catch (Exception e) {
            return absolutePath(path);
        }
    }
598728
public static String relativePath(String base,
                                      String pathSpec,
                                      String path )
    {
        String info=pathInfo(pathSpec,path);
        if (info==null)
            info=path;

        if( info.startsWith( "./"))
            info = info.substring( 2);
        if( base.endsWith( "/"))
            if( info.startsWith( "/"))
                path = base + info.substring(1);
            else
                path = base + info;
        else
            if( info.startsWith( "/"))
                path = base + info;
            else
                path = base + "/" + info;
        return path;
    }
708407
@SuppressWarnings("WeakerAccess")
    @NonNull
    public static Uri getUriForFile(@NonNull Context context, @NonNull Directory directory, @NonNull String relativePath) {
        final Uri.Builder builder = new Uri.Builder()
                .scheme(ContentResolver.SCHEME_CONTENT)
                .authority(getAuthority(context))
                .appendPath(directory.name().toLowerCase());
        for (String segment : relativePath.split(Pattern.quote(File.separator))) {
            if (segment.length() > 0) {
                builder.appendPath(segment);
            }
        }
        return builder.build();
    }
662803
public synchronized com.sun.tools.javac.util.List<String> getFiles(RelativeDirectory path) {
        try {
            checkIndex();

            DirectoryEntry de = directories.get(path);
            com.sun.tools.javac.util.List<String> ret = de == null ? null : de.getFiles();

            if (ret == null) {
                return com.sun.tools.javac.util.List.<String>nil();
            }
            return ret;
        }
        catch (IOException e) {
            return com.sun.tools.javac.util.List.<String>nil();
        }
    }
759646
public static Node getNode(Object root, String path) {
        return getNode(root, Path.create(path));
    }
1208009
public String getRealPath(String path)
    {
        if(log.isDebugEnabled())log.debug("getRealPath of "+path+" in "+this);

        if (__Slosh2Slash)
            path=path.replace('\\','/');
        path=URI.canonicalPath(path);
        if (path==null)
            return null;

        Resource baseResource=getHttpContext().getBaseResource();
        if (baseResource==null )
            return null;

        try{
            Resource resource = baseResource.addPath(path);
            File file = resource.getFile();

            return (file==null)?null:(file.getAbsolutePath());
        }
        catch(IOException e)
        {
            log.warn(LogSupport.EXCEPTION,e);
            return null;
        }
    }
741394
protected String getParentPath( String path ) {
        int slash = path.lastIndexOf('/');
        if (slash != -1) {
            return path.substring(0, slash);
        }
        return null;
    }
180925
def ensure_dir_path(self, path, relative=False):
        
        if not relative:
            rel_path = self.relpath(path)
        else:
            rel_path = path

        # Locator
        if self.is_locator(rel_path, relative=True):
            path = path.rstrip('/')

        # Directory
        elif rel_path:
            path = path.rstrip('/') + '/'
        # else: root
        return path
1115886
protected String getRelativePath(final HttpServletRequest request) {
		// IMPORTANT: DefaultServlet can be mapped to '/' or '/path/*' but
		// always
		// serves resources from the web app root with context rooted paths.
		// i.e. it can not be used to mount the web app root under a sub-path
		// This method must construct a complete context rooted path, although
		// subclasses can change this behaviour.

		// Are we being processed by a RequestDispatcher.include()?
		if (request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != null) {
			String result = (String) request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO);
			if (result == null) {
				result = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
			} else {
				result = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH) + result;
			}
			if ((result == null) || (result.equals(""))) {
				result = "/";
			}
			return (result);
		}

		// No, extract the desired path directly from the request
		String result = request.getPathInfo();
		if (result == null) {
			result = request.getServletPath();
		} else {
			result = request.getServletPath() + result;
		}
		if ((result == null) || (result.equals(""))) {
			result = "/";
		}
		return (result);

	}
1262785
def get_root_path(self, path):
        """"""
        # Look at the directories present in the current working directory. In
        # case a .svn directory is present, we know we are in the root directory
        # of a Subversion repository (for Subversion 1.7.x). In case no
        # repository specific folder is found, and the current directory has a
        # parent directory, look if a repository specific directory can be found
        # in the parent directory.
        while path != '/':
            if '.svn' in os.listdir(path):
                return path
            path = os.path.abspath(os.path.join(path, os.pardir))

        # No Subversion repository found.
        return None
611424
public static String getParent(String path) throws InvalidPathException {
    String cleanedPath = cleanPath(path);
    String name = FilenameUtils.getName(cleanedPath);
    String parent = cleanedPath.substring(0, cleanedPath.length() - name.length() - 1);
    if (parent.isEmpty()) {
      // The parent is the root path.
      return AlluxioURI.SEPARATOR;
    }
    return parent;
  }
752322
public static String getRelativePath(File file, File srcDir) {

		String base = srcDir.getPath();
		String filePath = file.getPath();

		String relativePath = new File(base).toURI()
				.relativize(new File(filePath).toURI()).getPath();
		return relativePath;
	}
656657
static String root(final ResourcePath path) {
        if (path.getDepth() == 1)
            return path.getResourcePath();
        throw new JaxRxException(404, "Resource not found: " + path);
    }
937667
public Resource getResource(String path) {
        final Resource descriptorResource = descriptor.getResource();

        try {
            Resource resource = descriptorResource.createRelative("static" + path);
            if (resource.exists()) {
                return resource;
            }
        } catch (IOException e) {
            return null;
        }
        return null;
    }