VersionControlPath Class

A utility class for manipulating version control items specifications. It contains routines for parsing, formatting, validating, and so on.

System.Object
  Microsoft.TeamFoundation.VersionControl.Common.VersionControlPath

Namespace:  Microsoft.TeamFoundation.VersionControl.Common
Assembly:  Microsoft.TeamFoundation.VersionControl.Common (in Microsoft.TeamFoundation.VersionControl.Common.dll)

public static class VersionControlPath

The VersionControlPath type exposes the following members.

  NameDescription
Public propertyStatic memberDepthFirstTreeComparerThis comparer can be used to sort version control paths depth-first, just like a tree traversal.
Public propertyStatic memberFullPathComparerReturns a string comparer for fully-specified server paths.
Public propertyStatic memberStringComparerThis is a property for comparison of server paths in instances like a Dictionary hash.
Top

  NameDescription
Public methodStatic memberCheckForIllegalDollarInPathThis method throws an InvalidPathException if there is a dollar sign ('$') that follows a path separator ('/'), because no part of a path can start with a dollar sign.
Public methodStatic memberCombine(String, String)Returns a fully qualified and canonicalized path constructed from parent and relative. If relative is already a fully qualified path, just return a canonicalized copy of relative. If relative is not fully qualified, return the path that results from appending relative to parent and canonicalizing the result. It is assumed that parent is already canonicalized.
Public methodStatic memberCombine(String, String, PathLength)Returns a fully qualified and canonicalized path constructed from parent and relative. If relative is already a fully qualified path, just return a canonicalized copy of relative. If relative is not fully qualified, return the path that results from appending relative to parent and canonicalizing the result. It is assumed that parent is already canonicalized.
Public methodStatic memberCombine(String, String, String)Given a base local path, base server path and target local path computes the target server path. This is completed by generating the relative path for the local paths, converting that to a server relative path and combining it with the base server path. Note: This method will throw an invalid path exception if it cannot generate the target server path. Possible reasons for this include the following: 1) local paths are on different drives and are not relative. 2) combining the calculated relative path with the base server path causes a "negative folder depth" (that is directory above root, $/). Examples: Combine(@"c:\myproj\abc\xyz", @"c:\myproj\abc\blech", @"$/abc") -> @"$/blech" Combine(@"c:\myproj\abc\xyz", @"c:\myproj\abc\xyz\x", @"$/xyz") -> @"$/xyz/x" Combine(@"c:\myproj\abc\xyz", @"c:\yourproj\abc\xyz\x", @"$/xyz") -> @"InvalidPathException" Combine(@"c:\myproj\abc\xyz", @"c:\yourproj\abc\xyz", @"$/myproj/abc/xyz") -> @"$/yourproj/abc/xyz"
Public methodStatic memberCombine(String, String, String, PathLength)Given a base local path, base server path and target local path computes the target server path. This is done by generating the relative path for the local paths, converting that to a server relative path and combining it with the base server path. Note: This method will throw an invalid path exception if it cannot generate the target server path. Possible reasons for this include: 1) local paths are on different drives and are not relative. 2) combining the calculated relative path with the base server path results in a "negative folder depth" (i.e. directory above root, $/). Examples: Combine(@"c:\myproj\abc\efg", @"c:\myproj\abc\blech", @"$/foo") -> @"$/blech" Combine(@"c:\myproj\abc\efg", @"c:\myproj\abc\efg\x", @"$/bar") -> @"$/efg/x" Combine(@"c:\myproj\abc\efg", @"c:\yourproj\abc\efg\x", @"$/bar") -> @"InvalidPathException" Combine(@"c:\myproj\abc\efg", @"c:\yourproj\abc\efg", @"$/myproj/abc/efg") -> @"$/yourproj/abc/efg"
Public methodStatic memberCompare(String, String)Compares two version control item paths.
Public methodStatic memberCompare(String, String, Int32, Int32)Compares two version control item paths.
Public methodStatic memberCompareCaseSensitiveCompares two Version Control item paths in a case-insensitive manner on every part of the path except for the last item in the path. The last item in the path is compared in a case-sensitive manner.
Public methodStatic memberCompareTopDownCompares two Version Control paths and return their relative ordering. This is like Compare except that it sorts grandchildren after children.
Public methodStatic memberCompareTopDownUICompares two Version Control paths and returns their relative ordering for display (culture and case insensitive). This is like Compare except that it sorts grandchildren after children.
Public methodStatic memberCompareUI(String, String)Compares two Version Control item paths for display (culture-sensitive and case-insensitive).
Public methodStatic memberCompareUI(String, String, Int32, Int32)Compares two Version Control item paths for display (culture-sensitive and case-insensitive).
Public methodStatic memberEqualsCompares two file specs for equality.
Public methodStatic memberEqualsCaseSensitiveChecks two file paths for equality. Returns whether they are equal in a case-insensitive manner on every part of the path except for the last item in the path. The last item in the path is compared in a case-sensitive manner.
Public methodStatic memberGetCommonParentGiven two server paths, returns the farthest item from $/ that parents both items. If one of the two paths is null, the other will be returned. If both paths are null, an ArgumentNullException is thrown.
Public methodStatic memberGetExtensionGets the file name extension from a version control specification.
Public methodStatic memberGetFileNameReturns the last path component from a canonicalized path. For example, passing "$/abc/xyz" would return "xyz". Passing "$/" will return "".
Public methodStatic memberGetFolderDepth(String)Returns the number of levels of path elements in this specification.$/ will return 0 $/abc will return 1 $/abc/xyz will return 2, and so on.
Public methodStatic memberGetFolderDepth(String, Int32)Returns the number of levels of path elements in this specification up to the maximum depth.$/ will return 0 $/abc will return 1 $/abc/xyz will return 2, and so on.
Public methodStatic memberGetFolderNameGets the parent folder for the specified canonicalized path. If "$/" is passed, "$/" is returned as the parent.
Public methodStatic memberGetFullPath(String)Canonicalizes the specified items specification and return the string. This will do things such as remove ..'s, convert \ to /, and so on. It throws an InvalidPathException if the item is the empty string, contains invalid characters including an embedded dollar sign (wildcard characters are not considered invalid in this check), or is too long.
Public methodStatic memberGetFullPath(String, PathLength)Canonicalizes the specified items specification and return the string. This will do things like remove ..'s, convert \ to /, etc. It throws an InvalidPathException if the item is the empty string, contains invalid characters including an embedded dollar sign (wildcards are not considered illegal in this check), or is too long.
Public methodStatic memberGetFullPath(String, Boolean)Canonicalizes the specified items specification and return the string. This will do things such as remove ..'s, convert \ to /, and so on. It throws an InvalidPathException if the item is the empty string, contains invalid characters including an embedded dollar sign (wildcard characters are not considered invalid in this check), or is too long.
Public methodStatic memberGetFullPath(String, Boolean, PathLength)Canonicalizes the specified items specification and return the string. This will do things like remove ..'s, convert \ to /, etc. It throws an InvalidPathException if the item is the empty string, contains invalid characters including an embedded dollar sign (wildcards are not considered illegal in this check), or is too long.
Public methodStatic memberGetRelativeStartIndexGiven a path and folder, returns the index of the substring in path relative to the folder. If the path is not under the folder then 0 is returned (meaning the entire path). MakeRelative(@"$/src/project/abc.cpp", @"$/src") -> 6 MakeRelative(@"$/src/project/abc.cpp", @"$/specs") -> 0 MakeRelative(@"$/src/project/abc.cpp", @"$/src/proj") -> 0
Public methodStatic memberGetTeamProjectReturns the top level "team project" folder given a server item.
Public methodStatic memberGetTeamProjectNameReturns the top level "team project" given a server item.
Public methodStatic memberIsCanonicalizedPath(String, Boolean)Returns true if the path is canonicalized. The path must not contain a $ at the start of a path part, or any invalid characters.
Public methodStatic memberIsCanonicalizedPath(String, Boolean, PathLength)Returns true if the path is canonicalized. The path must not contain a $ at the beginning of a path part, or any illegal characters.
Public methodStatic memberIsImmediateChildReturns true if item is an immediate child of parent.
Public methodStatic memberIsRootFolder
Public methodStatic memberIsServerItemReturns true if the specified string appears to be a server item (instead of a local item). The path is not required to be canonicalized. All server item paths are absolute.
Public methodStatic memberIsSubItemReturns true if the item is equal to or is under (in the heirarchy) parent.
Public methodStatic memberIsTeamProjectReturns whether the passed server item is a team project ($/abc, $/def, not $/abc/efg nor $/)
Public methodStatic memberIsValidFolderNameChecks if the specified folder name is valid. By folder name, we are referring to a single folder, not the full path. Wild cards are not allowed here. For example, a folder name in the full path below could be A, B, or C $/A/B/C/file.txt
Public methodStatic memberIsValidPath(String)Returns true if path is valid; false otherwise.
Public methodStatic memberIsValidPath(String, PathLength)Returns true if path is valid; false otherwise
Public methodStatic memberIsWildcardDetermines if the last component of the specified path contains a wildcard character. The path may be fully qualified.
Public methodStatic memberMakeRelative(String, String)Given a path and folder, returns the path relative to the folder. If the path is not under the folder the path is returned unmodified. Both path and folder are assumed to be in canonical form. Examples: MakeRelative(@"$/src/project/abc.cpp", @"$/src") -> @"project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/specs") -> @"$/src/project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/src/proj") -> @"$/src/project/abc.cpp"
Public methodStatic memberMakeRelative(String, String, Boolean)Given a path and folder, returns the path relative to the folder. If the path is not under the folder and the recursive parameter is false then path is returned unmodified. Otherwise, the method iteratively each parent directory in the specified folder and tries to make item relative. Both path and folder are assumed to be in canonical form. Examples: MakeRelative(@"$/src/project/abc.cpp", @"$/src",false) -> @"project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/specs",false) -> @"$/src/project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/src/proj",false) -> @"$/src/project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/src", true) -> @"project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/specs", true) -> @"../src/project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/src/proj", true) -> @"../project/abc.cpp"
Public methodStatic memberMatchCompares an item to see whether it matches a folder and a name that may be a wildcard. If recursive is true then any matching item under the matchFolder will match. Wildcard matching is performed by using the NT file system matching rules.
Public methodStatic memberMatchFileNameMatches just the final component of the specified item to the specified wildcard.
Public methodStatic memberParseParses a canonicalized item specification into a parent folder and the last path component. If "$/" is passed, the parent is "$/" and the name is "".
Public methodStatic memberPrependRootIfNeeded(String)Utility method to prepend the root ($/) to a folder - most useful for getting the folder of a team project if you only have his name.
Public methodStatic memberPrependRootIfNeeded(String, PathLength)Utility method to prepend the root ($/) to a folder - most useful for getting the folder of a team project if you only have his name.
Public methodStatic memberValidatePath(String)Validates the server path. Wildcards are not allowed. Exception is thrown if invalid.
Public methodStatic memberValidatePath(String, PathLength)Validates the server path. Wildcards are not allowed Exception is thrown if invalid.
Top

  NameDescription
Public fieldStatic memberRootFolder
Public fieldStatic memberSeparator
Top

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft