|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.javascript.jscomp.deps.PathUtil
public final class PathUtil
Utility methods for manipulation of UNIX-like paths. NOTE: According to kevinb, equivalent methods will be in the standard library once jsr203 is ready.
Method Summary | |
---|---|
static String |
collapseDots(String path)
Removes all ../ and ./ entries from within the given path. |
static String |
makeAbsolute(String path)
Converts the given path into an absolute one. |
static String |
makeAbsolute(String path,
String rootPath)
Converts the given path into an absolute one. |
static String |
makeRelative(String basePath,
String targetPath)
Returns targetPath relative to basePath. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static String collapseDots(String path)
path
- The path to remove dots from.
public static String makeAbsolute(String path)
Unlike File.getAbsolutePath(), this function does remove .'s from the path and unlike File.getCanonicalPath(), this function does not resolve symlinks and does not use filesystem calls.
path
- The path to make absolute.
public static String makeAbsolute(String path, String rootPath)
Unlike File.getAbsolutePath(), this function does remove .'s from the path and unlike File.getCanonicalPath(), this function does not resolve symlinks and does not use filesystem calls.
rootPath
- The path to prefix to path if path is not already absolute.path
- The path to make absolute.
public static String makeRelative(String basePath, String targetPath)
basePath and targetPath must either both be relative, or both be absolute paths.
This function is different from makeRelative in that it is able to add in ../ components and collapse existing ones as well.
Examples: base="some/relative/path" target="some/relative/path/foo" return="foo" base="some/relative/path" target="some/relative" return=".." base="some/relative/path" target="foo/bar" return="../../../foo/bar" base="/some/abs/path" target="/foo/bar" return="../../../foo/bar"
basePath
- The path to make targetPath relative to.targetPath
- The path to make relative.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |