com.microsoft.tfs.core.clients.versioncontrol.path
Class LocalPath

java.lang.Object
  extended by com.microsoft.tfs.core.clients.versioncontrol.path.LocalPath

public abstract class LocalPath
extends java.lang.Object

Static methods to process local (disk) paths.

Warnings:
Character case is not consistently ignored among all methods of this class. The host platform's conventional behavior with regards to case sensitivity will determine whether two strings differing only in case reference the same file in most methods, but a few are documented to only work without respect to character case. Look at the Javadoc of each method for details.
Since:
TEE-SDK-10.1
Thread-safety:
thread-safe

Field Summary
static java.util.Comparator<java.lang.String> BOTTOM_UP_COMPARATOR
          Compares well-formed local path strings in a bottom-up fashion (children sort before their parents).
static java.lang.String GENERAL_LOCAL_PATH_SEPARATOR
           
static char TFS_PREFERRED_LOCAL_PATH_SEPARATOR
           
static java.util.Comparator<java.lang.String> TOP_DOWN_COMPARATOR
          Compares well-formed local path strings in a top-down fashion (parents sort before their children).
 
Constructor Summary
LocalPath()
           
 
Method Summary
static java.lang.String addTrailingSeparator(java.lang.String path)
          Returns the given path string with a trailing separator (as specified by File.separator).
static java.lang.String canonicalize(java.lang.String path)
           Gets the canonical form of the given path.
static void check8Dot3Aliases(java.lang.String item)
          Checks whether the given item contains any 8.3 aliases and throws if it does.
static void checkForIllegalDollarInPath(java.lang.String path)
          This method throws an InvalidPathException if there is a dollar sign ('$') that follows a path separator ('/' or '\') since no part of a path is allowed to start with a dollar sign.
static ItemValidationError checkLocalItem(java.lang.String item, java.lang.String parameterName, boolean allowNull, boolean allowWildcards, boolean allow8Dot3Paths, boolean checkReservedCharacters)
           
static java.lang.String combine(java.lang.String parent, java.lang.String relative)
          Combines the two given paths into one path string, using this platform's preferred path separator character.
static int compareBottomUp(java.lang.String pathA, java.lang.String pathB)
          Compares two server paths (ordinal character comparison) placing parents after their children.
static int compareTopDown(java.lang.String pathA, java.lang.String pathB)
          Compares two local paths (ordinal character comparison) placing children after their parents.
static boolean endsWith(java.lang.String path, java.lang.String suffix)
           
static boolean equals(java.lang.String path1, java.lang.String path2)
           Compares two local paths for equality.
static boolean equals(java.lang.String path1, java.lang.String path2, boolean forceIgnoreCase)
           Compares two local paths for equality, optionally forcing the comparison to ignore character case.
static boolean exists(java.lang.String filePath)
          Helper method to check whether a file/dir exists
protected static java.lang.String expandTildeToHome(java.lang.String pathString)
           Expands any "~user" or "~" sequences in the given local path string to the absolute paths to those directories, preserving any trailing path parts.
static java.lang.String getCommonPathPrefix(java.lang.String path1, java.lang.String path2)
          Given two canonicalized paths (that never end with a filesystem separator except for a drive letter root on Windows), returns the longest path prefix which is common to both paths.
static java.lang.String getCurrentWorkingDirectory()
          Gets the full path to the current working directory.
static java.lang.String getDirectory(java.lang.String path)
          Returns the directory part of the local path.
static java.lang.String getFileExtension(java.lang.String localPath)
          Gets the extension of the given local path -- everything from the last '.' of the file part (including the '.').
static java.lang.String getFileName(java.lang.String localPath)
          Gets just the file part of the given local path, which is all of the string after the last path component.
static int getFolderDepth(java.lang.String localPath)
          Calls getFolderDepth(String, Platform) with Platform.getCurrentPlatform() as the Platform argument.
static int getFolderDepth(java.lang.String localPath, com.microsoft.tfs.util.Platform platform)
           Returns the depth of the item described by path, where the root folder is depth 0, items in root are 1, items below that are 2, etc.
static java.lang.String[] getHierarchy(java.lang.String path)
          Returns all directories leading up to (and including) the given path, from the root of the local filesystem.
static java.lang.String[] getHierarchy(java.lang.String fromPath, java.lang.String toPath)
          Get file hierarchy from fromPath to toPath e.g.
static java.lang.String getLastComponent(java.lang.String path)
          Return the the last path component in the supplied path.
static java.lang.String getParent(java.lang.String path)
          Returns the parent directory name of the given local path.
static java.lang.String getPathRoot(java.lang.String path)
          Returns the root portion of the given path.
protected static java.lang.String getPathRoot(java.lang.String path, com.microsoft.tfs.util.Platform platform)
           
protected static int getRootLength(java.lang.String path)
           
protected static int getRootLength(java.lang.String path, com.microsoft.tfs.util.Platform platform)
          Gets the length of the root DirectoryInfo or whatever DirectoryInfo markers are specified for the first part of the DirectoryInfo name.
static int hashCode(java.lang.String localPath)
          Returns a hash code for the given local path.
static boolean hasVersionControlReservedCharacter(java.lang.String path, java.util.concurrent.atomic.AtomicReference<java.lang.Character> c)
          Returns true if the path contains any character which is a version control reserved character.
static boolean isChild(java.lang.String parentPath, java.lang.String possibleChild)
           Tests the given paths for a parent-child relationship.
static boolean isDirectChild(java.lang.String parentPath, java.lang.String possibleChild)
          Tests whether one path is a direct child of another path (which would be the parent).
static boolean isDirectoryEmpty(java.lang.String localPath)
          Tests whether a directory is empty (contains no files or directories).
static boolean isPathRooted(java.lang.String path)
          Tests whether the given path starts with a drive root prefix.
static boolean isWildcard(java.lang.String localPath)
           Tests whether the given local path contains wildcard characters in its final path element.
static boolean lastPartEqualsCaseSensitive(java.lang.String path1, java.lang.String path2)
          Compare two file paths in a platform-default-case-sensitivity fashion on every portion of the path except for the last item in the path.
static java.lang.String makeRelative(java.lang.String localPath, java.lang.String relativeTo)
           Returns a new string describing the first given path made relative to the second given path.
static java.lang.String makeServer(java.lang.String localPath, java.lang.String relativeToLocalPath, java.lang.String serverRoot)
           Maps a local path to a server path, given a parent local path of the path to be mapped, and a server path that corresponds to the parent.
static boolean matchesWildcard(java.lang.String firstItemPath, java.lang.String secondItemFolderPath, java.lang.String secondItemWildcardPattern, boolean recursive)
           Matches one item against a wildcard tuple (item path and wildcard pattern to apply to that item path), optionally allowing recursive matches.
static java.lang.String nativeToTFS(java.lang.String localPath)
          Converts this platform's file path to TFS's preferred separator (backslash) and roots it in a DOS-style drive letter if not already rooted in one.
static java.lang.String removeTrailingSeparators(java.lang.String path)
          Returns the given path string without trailing separators (as specified by File.separator).
static boolean startsWith(java.lang.String path, java.lang.String prefix)
           
static java.lang.String tfsToNative(java.lang.String localPath)
          Converts a TFS-style path into this platform's pathstyle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TFS_PREFERRED_LOCAL_PATH_SEPARATOR

public static final char TFS_PREFERRED_LOCAL_PATH_SEPARATOR
Constant Field Value:
92
See Also:
Constant Field Values

GENERAL_LOCAL_PATH_SEPARATOR

public static final java.lang.String GENERAL_LOCAL_PATH_SEPARATOR
Constant Field Value:
"/"
See Also:
Constant Field Values

TOP_DOWN_COMPARATOR

public static final java.util.Comparator<java.lang.String> TOP_DOWN_COMPARATOR
Compares well-formed local path strings in a top-down fashion (parents sort before their children).


BOTTOM_UP_COMPARATOR

public static final java.util.Comparator<java.lang.String> BOTTOM_UP_COMPARATOR
Compares well-formed local path strings in a bottom-up fashion (children sort before their parents).

Constructor Detail

LocalPath

public LocalPath()
Method Detail

getCurrentWorkingDirectory

public static final java.lang.String getCurrentWorkingDirectory()
Gets the full path to the current working directory.

Returns:
the full path to the current working directory.

equals

public static final boolean equals(java.lang.String path1,
                                   java.lang.String path2)

Compares two local paths for equality. Character case is honored when the operating system is case-sensitive ( FileHelpers.doesFileSystemIgnoreCase()). Paths are not normalized (".." segments removed) before comparison.

Two null paths are equal, but a null path does not equal a non-null path.

Parameters:
path1 - the first local path (may be null)
path2 - the second local path (may be null)
Returns:
true if the paths are equal, false if not.

equals

public static final boolean equals(java.lang.String path1,
                                   java.lang.String path2,
                                   boolean forceIgnoreCase)

Compares two local paths for equality, optionally forcing the comparison to ignore character case. Paths are not normalized (".." segments removed) before comparison.

Two null paths are equal, but a null path does not equal a non-null path.

Parameters:
path1 - the first local path (may be null)
path2 - the second local path (may be null)
forceIgnoreCase - if true, case is always ignored in the comparison. If false, case is only ignored if FileHelpers.doesFileSystemIgnoreCase() returns true
Returns:
true if the paths are equal, false if not.
See Also:
hashCode(String)

startsWith

public static final boolean startsWith(java.lang.String path,
                                       java.lang.String prefix)

endsWith

public static final boolean endsWith(java.lang.String path,
                                     java.lang.String suffix)

lastPartEqualsCaseSensitive

public static final boolean lastPartEqualsCaseSensitive(java.lang.String path1,
                                                        java.lang.String path2)
Compare two file paths in a platform-default-case-sensitivity fashion on every portion of the path except for the last item in the path. The last item in the path is compared in a case-sensitive fashion.

Parameters:
path1 - the first local path (must not be null)
path2 - the second local path (must not be null)
Returns:
true if the paths differ, false if they are the same
See Also:
FileHelpers.doesFileSystemIgnoreCase()

hashCode

public static final int hashCode(java.lang.String localPath)
Returns a hash code for the given local path. This method for calculating hash codes must be used when equals(String, String) is used to test for equality so the case-sensitivity behavior matches (and the hashCode/equals contract is maintained).

Parameters:
localPath - the local path to compute the hash code for (must not be null)
Returns:
the hash code value

isDirectChild

public static boolean isDirectChild(java.lang.String parentPath,
                                    java.lang.String possibleChild)
Tests whether one path is a direct child of another path (which would be the parent).

Parameters:
parentPath - the path to the parent folder (must not be null)
possibleChild - the path of the possible child item (must not be null )
Returns:
true if the possibleChild is a direct child of the parentPath

isChild

public static final boolean isChild(java.lang.String parentPath,
                                    java.lang.String possibleChild)

Tests the given paths for a parent-child relationship. A path is a child of another if the object it describes would reside below the object described by the parent path in the local filesystem. Case is respected on a per-platform basis.

A possible child that is equivalent to the parent path (both refer to the same object) is considered a child. This is compatible with Visual Studio's behavior.

The given paths are not canonicalized before testing.

The given paths must be in the OS's native path format.

Parameters:
parentPath - the local path to the parent item (not null).
possibleChild - the local path of the possible child item (not null).
Returns:
true if possibleChild is a child of parentPath, false otherwise (including I/O errors accessing either path).

isDirectoryEmpty

public static final boolean isDirectoryEmpty(java.lang.String localPath)
Tests whether a directory is empty (contains no files or directories).

Parameters:
localPath - the local directory path to test (must not be null)
Returns:
true if the given path contains no directories or files, false if it contains directories or files.

tfsToNative

public static final java.lang.String tfsToNative(java.lang.String localPath)
Converts a TFS-style path into this platform's pathstyle. On Windows, the string is unaltered, on Unix the drive letter is removed and the backslashes are converted to slashes.

Parameters:
localPath - the TFS-style local path string to convert. If null, null is returned.
Returns:
this platform's preferred style of local path string, null if the given localPath was null.

nativeToTFS

public static final java.lang.String nativeToTFS(java.lang.String localPath)
Converts this platform's file path to TFS's preferred separator (backslash) and roots it in a DOS-style drive letter if not already rooted in one.

Parameters:
localPath - the absolute local path string to convert to TFS-style separators. If null, null is returned.
Returns:
the TFS-style path, which looks like an absolute Windows path name, null if the given localPath was null.

getFolderDepth

public static int getFolderDepth(java.lang.String localPath)
Calls getFolderDepth(String, Platform) with Platform.getCurrentPlatform() as the Platform argument.

See Also:
getFolderDepth(String, Platform)

getFolderDepth

public static int getFolderDepth(java.lang.String localPath,
                                 com.microsoft.tfs.util.Platform platform)

Returns the depth of the item described by path, where the root folder is depth 0, items in root are 1, items below that are 2, etc. UNC paths are supported on Windows, but are not supported on other platforms (an exception is thrown). The path must be absolute, well-formed, and must not contain . or .. segments.

UNC Paths

On Windows, UNC paths and drive letters are supported. In this case a string like "\\server\share\" is the root path (depth 0). If the share name part is not specified, IllegalArgumentException is thrown.

On non-Windows platforms, parsing UNC and drive letter paths is undefined because those paths would not be valid absolute local paths (all absolute paths must start with "/" and UNC and drive letters do not).

Safe for remote paths. Does not access the local disk or network shares.


combine

public static final java.lang.String combine(java.lang.String parent,
                                             java.lang.String relative)
Combines the two given paths into one path string, using this platform's preferred path separator character. If relative is an absolute path, it is returned as the entire return value (parent is discarded).

Parameters:
parent - the first (left-side) path component (must not be null)
relative - the second (right-side) path component (must not be null)

getHierarchy

public static java.lang.String[] getHierarchy(java.lang.String path)
Returns all directories leading up to (and including) the given path, from the root of the local filesystem. Note that canonical parents are returned.

Parameters:
path - the path to get parent paths for (must not be null)
Returns:
the canonical parent path strings

getHierarchy

public static java.lang.String[] getHierarchy(java.lang.String fromPath,
                                              java.lang.String toPath)
Get file hierarchy from fromPath to toPath e.g. if fromPath is /usr/local/bin, toPath is /usr, hierarchy is [usr, local, bin] fromPath has to be beneath (child of) toPath

Parameters:
fromPath -
Path -
Returns:

getParent

public static java.lang.String getParent(java.lang.String path)
Returns the parent directory name of the given local path. Note that this differs from getDirectory(String) in that it will always return the parent path, regardless of whether path is a file or folder.

Parameters:
path - the local path (file or directory) to get the parent directory of (must not be null)
Returns:
the parent directory of the given path.

getDirectory

public static java.lang.String getDirectory(java.lang.String path)
Returns the directory part of the local path. If the path describes a directory, the same path is returned. If the path describes a file, the path to its parent directory is returned.

Parameters:
path - the local path (file or directory) to get the directory part of (must not be null)
Returns:
the directory part of the given path.

getFileName

public static java.lang.String getFileName(java.lang.String localPath)
Gets just the file part of the given local path, which is all of the string after the last path component. If there are no separators, the entire string is returned. If the string ends in a separator, an empty string is returned.

Parameters:
localPath - the local path from which to parse the file part (must not be null)
Returns:
the file name at the end of the given local path, or the given path if no separator characters were found, or an empty string if the given path ends with a separator.

getFileExtension

public static java.lang.String getFileExtension(java.lang.String localPath)
Gets the extension of the given local path -- everything from the last '.' of the file part (including the '.'). If there is no dot, an empty string is returned.

Parameters:
localPath - the local path to parse the extension from (must not be null)
Returns:
the file extension at the end of the given path, or an empty string if no extension separator ('.') exists.

getLastComponent

public static final java.lang.String getLastComponent(java.lang.String path)
Return the the last path component in the supplied path. If an empty string is supplied for the path, an empty string is returned.

Parameters:
path - the path string to examine (must not be null)
Returns:
the last path component of the given path string, which would be the file name if the path string references a file, and the directory furthest down the hierarchy if the path references a directory.

compareTopDown

public static final int compareTopDown(java.lang.String pathA,
                                       java.lang.String pathB)
Compares two local paths (ordinal character comparison) placing children after their parents. Ignores case if the current platform does. Paths are not normalized (".." segments removed) before comparison.

If sorting paths for display to the user, better to use a Collator-based comparison instead of this one.

Parameters:
pathA - the first path to compare (must not be null)
pathB - the second path to compare (must not be null)
Returns:
see Comparable.compareTo(Object)
See Also:
FileHelpers.doesFileSystemIgnoreCase()

compareBottomUp

public static final int compareBottomUp(java.lang.String pathA,
                                        java.lang.String pathB)
Compares two server paths (ordinal character comparison) placing parents after their children. Ignores case if the current platform does. Paths are not normalized (".." segments removed) before comparison.

If sorting paths for display to the user, better to use a Collator-based comparison instead of this one.

Parameters:
pathA - the first path to compare (must not be null)
pathB - the second path to compare (must not be null)
Returns:
see Comparable.compareTo(Object)
See Also:
FileHelpers.doesFileSystemIgnoreCase()

canonicalize

public static final java.lang.String canonicalize(java.lang.String path)

Gets the canonical form of the given path. On Unix platforms (including Mac OS X), a path that begins with "~" or "~user", where user is a user name on this host, is expanded to the full path to the absolute path to the user's home directory (and any other path components, of course).

On case-preserving but case-insensitive filesystems, this implementation differs from Java's File.getCanonicalPath() in one important way: if the given path string refers to a filesystem object (file or directory) that exists on disk but has a name (not path) that differs only in character case, the path is still made canonical according to File.getCanonicalPath() but the character case of the final path element (object's name) is taken from the given path. If the given path does not exist on disk, or does exist but the final elements have matching character case, the path returned by File.getCanonicalPath() is returned. This behavior allows us to make a relative path string "canonical" (in the LocalPath way) and support the case-changing rename case (where only the case of the file changes).

On case-sensitive filesystems (most Unixes, not Mac OS X) this method behaves exactly like Java's File.getCanonicalPath().

Parameters:
path - the path to canonicalize. If null is given, null is returned.
Returns:
the canonical version of the given path, null if path was null.

isWildcard

public static boolean isWildcard(java.lang.String localPath)

Tests whether the given local path contains wildcard characters in its final path element. Wildcards in initial path elements (intermediate directories) are ignored.

Character case is ignored during wildcard matching.

Parameters:
localPath - the local path to test for wildcards (in last element only). Not null.
Returns:
true if the last path element contains wildcards, false otherwise.

matchesWildcard

public static final boolean matchesWildcard(java.lang.String firstItemPath,
                                            java.lang.String secondItemFolderPath,
                                            java.lang.String secondItemWildcardPattern,
                                            boolean recursive)

Matches one item against a wildcard tuple (item path and wildcard pattern to apply to that item path), optionally allowing recursive matches.

Character case is ignored during wildcard matching.

Parameters:
firstItemPath - the item to test against the wildcard pattern. This is a full path (must not be null)
secondItemFolderPath - a path where the wildcard pattern will be applied to find the item described by firstItemPath. If this parameter is a child of firstItemPath, there wildcard pattern will never match. If this parameter is a direct parent of firstItemPath, the wildcard can match. If this parameter is a grandparent (or greater), the pattern can only match if the recursive parameter is true. If this parameter is null, false is returned.
secondItemWildcardPattern - the wildcard pattern to apply to secondItemFolderPath.
recursive - if true, the wildcard pattern will apply to secondItemFolderPath and all its possible children. If false, the wildcard pattern will only match direct children of secondItemFolderPath.
Returns:
true if the firstItemPath matches the wildcard specification, false if it does not.

makeRelative

public static java.lang.String makeRelative(java.lang.String localPath,
                                            java.lang.String relativeTo)

Returns a new string describing the first given path made relative to the second given path.

Character case is ignored during string comparison, so strings with mismatched-in-case common elements will still succeed in being made relative.

Paths are not normalized (for ending separators, case, etc.). It is the caller's responsibility to make sure the relativeTo path can be matched.

Parameters:
localPath - the path to the local item to describe (must not be null)
relativeTo - the path that the first parameter will be described relative to (must not be null)
Returns:
the relative path, or the unaltered given local path if it could not be made relative to the second path.

makeServer

public static java.lang.String makeServer(java.lang.String localPath,
                                          java.lang.String relativeToLocalPath,
                                          java.lang.String serverRoot)

Maps a local path to a server path, given a parent local path of the path to be mapped, and a server path that corresponds to the parent.

Character case is ignored during string comparison, so strings with mismatched-in-case common elements will still succeed in being made relative.

Paths are not normalized (for ending separators, case, etc.). It is the caller's responsibility to make sure the relativeToLocalPath path can be matched.

Parameters:
localPath - the local path to convert to a server path (must not be null)
relativeToLocalPath - the parent local path (must not be null and must be a parent of localPath)
serverRoot - the server path that corresponds to relativeToLocalPath (must not be null)
Returns:
the corresponding server path (never null)

removeTrailingSeparators

public static java.lang.String removeTrailingSeparators(java.lang.String path)
Returns the given path string without trailing separators (as specified by File.separator).

Parameters:
path - the string to strip trailing separators from.
Returns:
the given string with all trailing separators removed.

addTrailingSeparator

public static java.lang.String addTrailingSeparator(java.lang.String path)
Returns the given path string with a trailing separator (as specified by File.separator).

Parameters:
path - the string to add a trailing separator.
Returns:
the given string with a trailing separator added.

expandTildeToHome

protected static java.lang.String expandTildeToHome(java.lang.String pathString)

Expands any "~user" or "~" sequences in the given local path string to the absolute paths to those directories, preserving any trailing path parts. The JNI home directory lookup is only performed if this platform is not Windows and the "~user" format is encountered.

Also, leading whitespace is always removed from the given path string.

Parameters:
pathString - the path string to expand for tildes (must not be null)
Returns:
the path string with "~user" and "~" expanded; the given string is returned unaltered (except for the removal of leading whitespace) if the username cannot be found or does not start with a "~".

checkLocalItem

public static ItemValidationError checkLocalItem(java.lang.String item,
                                                 java.lang.String parameterName,
                                                 boolean allowNull,
                                                 boolean allowWildcards,
                                                 boolean allow8Dot3Paths,
                                                 boolean checkReservedCharacters)

hasVersionControlReservedCharacter

public static boolean hasVersionControlReservedCharacter(java.lang.String path,
                                                         java.util.concurrent.atomic.AtomicReference<java.lang.Character> c)
Returns true if the path contains any character which is a version control reserved character.

Parameters:
path - the string to check for invalid characters (must not be null)
c - a reference to a Character where the invalid detected character will be stored if the method returns true (no character is stored if the method returns false ) (may be null)
Returns:
true if the path contains any version control reserved characters, false if it does not

check8Dot3Aliases

public static void check8Dot3Aliases(java.lang.String item)
Checks whether the given item contains any 8.3 aliases and throws if it does.


isPathRooted

public static boolean isPathRooted(java.lang.String path)
Tests whether the given path starts with a drive root prefix. A path is considered rooted if it starts with a backslash ("\"), slash ("/"), or a drive letter and a colon (":"). The Java File roots list is not consulted.

Parameters:
path - the local path to test (may be null)
Returns:
true if the path is rooted, false otherwise (including if the path was null or empty)

getPathRoot

public static java.lang.String getPathRoot(java.lang.String path)
Returns the root portion of the given path. The resulting string consists of those rightmost characters of the path that constitute the root of the path. Possible patterns for the resulting string are: An empty string (a relative path on the current drive), "/" an absolute Unix path, "\" (an absolute path on the current drive), "X:" (a relative path on a given drive, where X is the drive letter), "X:\" (an absolute path on a given drive), and "\\server\share" (a UNC path for a given server and share name). The resulting string is null if path is null.

Parameters:
path - the path to get the root for (may be null)
Returns:
the root portion of the path (null if a null path was given)

getPathRoot

protected static java.lang.String getPathRoot(java.lang.String path,
                                              com.microsoft.tfs.util.Platform platform)

getRootLength

protected static int getRootLength(java.lang.String path)
See Also:
getRootLength(String, Platform)

getRootLength

protected static int getRootLength(java.lang.String path,
                                   com.microsoft.tfs.util.Platform platform)
Gets the length of the root DirectoryInfo or whatever DirectoryInfo markers are specified for the first part of the DirectoryInfo name. From the .NET Path class implementation, but with NTFS validity enforcements on all platforms because we might send the chars to TFS later.

Parameters:
path - the local path to get the root length for (must not be null)
platform - the Platform whose path conventions should be used (must not be null)

checkForIllegalDollarInPath

public static void checkForIllegalDollarInPath(java.lang.String path)
This method throws an InvalidPathException if there is a dollar sign ('$') that follows a path separator ('/' or '\') since no part of a path is allowed to start with a dollar sign.

Parameters:
path - the path to check (path must already be canonicalized)

getCommonPathPrefix

public static java.lang.String getCommonPathPrefix(java.lang.String path1,
                                                   java.lang.String path2)
Given two canonicalized paths (that never end with a filesystem separator except for a drive letter root on Windows), returns the longest path prefix which is common to both paths.

Parameters:
path1 - the first path (must not be null or empty)
path2 - the second path (must not be null or empty)
Returns:
longest path prefix common to both paths. null if the paths have nothing in common

exists

public static boolean exists(java.lang.String filePath)
Helper method to check whether a file/dir exists

Parameters:
filePath -
Returns:


© 2015 Microsoft. All rights reserved.