Class PathUtil


  • public class PathUtil
    extends Object
    Restriction:
    This class is not intended to be subclassed by clients.
    Restriction:
    This class is not intended to be instantiated by clients.
    • Constructor Summary

      Constructors 
      Constructor Description
      PathUtil()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean equal​(org.eclipse.core.runtime.IPath path1, org.eclipse.core.runtime.IPath path2)
      Deprecated.
      static boolean equalPath​(org.eclipse.core.runtime.IPath path1, org.eclipse.core.runtime.IPath path2)
      Checks whether path1 is the same as path2.
      static org.eclipse.core.runtime.IPath findProgramLocation​(String prog)
      Finds location of the program inspecting each path in the path list defined by environment variable ${PATH}.
      static org.eclipse.core.runtime.IPath findProgramLocation​(String prog, String pathsStr)
      Finds location of the program inspecting each path in the path list.
      static org.eclipse.core.runtime.IPath getCanonicalPath​(org.eclipse.core.runtime.IPath fullPath)
      Return the canonical path (or the passed in path, if one couldn't be found).
      static org.eclipse.core.runtime.IPath getCanonicalPathWindows​(org.eclipse.core.runtime.IPath fullPath)
      On Windows returns the File.getCanonicalPath() for a given absolute path.
      static org.eclipse.core.resources.IProject getEnclosingProject​(org.eclipse.core.runtime.IPath fullPath)  
      static org.eclipse.core.runtime.IPath getProjectRelativePath​(org.eclipse.core.runtime.IPath fullPath, org.eclipse.core.resources.IProject project)  
      static org.eclipse.core.runtime.IPath getRawLocation​(org.eclipse.core.runtime.IPath wsRelativePath)  
      static org.eclipse.core.runtime.IPath getValidEnclosingFolder​(org.eclipse.core.runtime.IPath fullPath)  
      static org.eclipse.core.runtime.IPath getWorkspaceRelativePath​(String fullPath)  
      static org.eclipse.core.runtime.IPath getWorkspaceRelativePath​(org.eclipse.core.runtime.IPath fullPath)  
      static org.eclipse.core.resources.IWorkspaceRoot getWorkspaceRoot()  
      static boolean isPrefix​(org.eclipse.core.runtime.IPath path1, org.eclipse.core.runtime.IPath path2)
      Checks whether path1 is a prefix of path2.
      static boolean isWindowsFileSystem()  
      static org.eclipse.core.runtime.IPath makeRelativePath​(org.eclipse.core.runtime.IPath path, org.eclipse.core.runtime.IPath relativeTo)  
      static org.eclipse.core.runtime.IPath makeRelativePathToIncludes​(org.eclipse.core.runtime.IPath fullPath, String[] includePaths)  
      static org.eclipse.core.runtime.IPath makeRelativePathToProjectIncludes​(org.eclipse.core.runtime.IPath fullPath, org.eclipse.core.resources.IProject project)  
      static int matchingFirstSegments​(org.eclipse.core.runtime.IPath path1, org.eclipse.core.runtime.IPath path2)
      Returns the number of segments which match in path1 and path2 (device ids are ignored), comparing in increasing segment number order.
    • Constructor Detail

      • PathUtil

        public PathUtil()
    • Method Detail

      • isWindowsFileSystem

        public static boolean isWindowsFileSystem()
      • getWorkspaceRoot

        public static org.eclipse.core.resources.IWorkspaceRoot getWorkspaceRoot()
      • getCanonicalPath

        public static org.eclipse.core.runtime.IPath getCanonicalPath​(org.eclipse.core.runtime.IPath fullPath)
        Return the canonical path (or the passed in path, if one couldn't be found).
        Parameters:
        fullPath -
        Returns:
        canonicalized IPath or passed in fullPath.
      • getCanonicalPathWindows

        public static org.eclipse.core.runtime.IPath getCanonicalPathWindows​(org.eclipse.core.runtime.IPath fullPath)
        On Windows returns the File.getCanonicalPath() for a given absolute path. On other platforms, and for relative paths returns the the original path.
        Parameters:
        fullPath -
        Returns:
        canonicalized IPath or passed in fullPath.
        Since:
        5.3
      • getWorkspaceRelativePath

        public static org.eclipse.core.runtime.IPath getWorkspaceRelativePath​(org.eclipse.core.runtime.IPath fullPath)
      • getProjectRelativePath

        public static org.eclipse.core.runtime.IPath getProjectRelativePath​(org.eclipse.core.runtime.IPath fullPath,
                                                                            org.eclipse.core.resources.IProject project)
      • getWorkspaceRelativePath

        public static org.eclipse.core.runtime.IPath getWorkspaceRelativePath​(String fullPath)
      • getRawLocation

        public static org.eclipse.core.runtime.IPath getRawLocation​(org.eclipse.core.runtime.IPath wsRelativePath)
      • makeRelativePath

        public static org.eclipse.core.runtime.IPath makeRelativePath​(org.eclipse.core.runtime.IPath path,
                                                                      org.eclipse.core.runtime.IPath relativeTo)
      • makeRelativePathToProjectIncludes

        public static org.eclipse.core.runtime.IPath makeRelativePathToProjectIncludes​(org.eclipse.core.runtime.IPath fullPath,
                                                                                       org.eclipse.core.resources.IProject project)
      • makeRelativePathToIncludes

        public static org.eclipse.core.runtime.IPath makeRelativePathToIncludes​(org.eclipse.core.runtime.IPath fullPath,
                                                                                String[] includePaths)
      • getEnclosingProject

        public static org.eclipse.core.resources.IProject getEnclosingProject​(org.eclipse.core.runtime.IPath fullPath)
      • getValidEnclosingFolder

        public static org.eclipse.core.runtime.IPath getValidEnclosingFolder​(org.eclipse.core.runtime.IPath fullPath)
      • equal

        @Deprecated
        public boolean equal​(org.eclipse.core.runtime.IPath path1,
                             org.eclipse.core.runtime.IPath path2)
        Deprecated.
        Checks whether path1 is the same as path2.

        Similar to IPath.equals(Object obj), but takes case sensitivity of the file system into account.

        Returns:
        true if path1 is the same as path2, and false otherwise
        Since:
        5.1
      • equalPath

        public static boolean equalPath​(org.eclipse.core.runtime.IPath path1,
                                        org.eclipse.core.runtime.IPath path2)
        Checks whether path1 is the same as path2.

        Similar to IPath.equals(Object obj), but takes case sensitivity of the file system into account.

        Returns:
        true if path1 is the same as path2, and false otherwise
        Since:
        5.3
      • isPrefix

        public static boolean isPrefix​(org.eclipse.core.runtime.IPath path1,
                                       org.eclipse.core.runtime.IPath path2)
        Checks whether path1 is a prefix of path2. To be a prefix, path1's segments must appear in path1 in the same order, and their device ids must match.

        An empty path is a prefix of all paths with the same device; a root path is a prefix of all absolute paths with the same device.

        Similar to IPath.isPrefixOf(IPath anotherPath), but takes case sensitivity of the file system into account.

        Returns:
        true if path1 is a prefix of path2, and false otherwise
        Since:
        5.1
      • matchingFirstSegments

        public static int matchingFirstSegments​(org.eclipse.core.runtime.IPath path1,
                                                org.eclipse.core.runtime.IPath path2)
        Returns the number of segments which match in path1 and path2 (device ids are ignored), comparing in increasing segment number order.

        Similar to IPath.matchingFirstSegments(IPath anotherPath), but takes case sensitivity of the file system into account.

        Returns:
        the number of matching segments
        Since:
        5.1
      • findProgramLocation

        public static org.eclipse.core.runtime.IPath findProgramLocation​(String prog,
                                                                         String pathsStr)
        Finds location of the program inspecting each path in the path list.
        Parameters:
        prog - - program to find. For Windows, extensions "com" and "exe" can be omitted.
        pathsStr - - the list of paths to inspect separated by path separator defined in the platform (i.e. ":" in Unix and ";" in Windows). In case pathStr is null environment variable ${PATH} is inspected.
        Returns:
        - absolute location of the file on the file system or null if not found.
        Since:
        5.3
      • findProgramLocation

        public static org.eclipse.core.runtime.IPath findProgramLocation​(String prog)
        Finds location of the program inspecting each path in the path list defined by environment variable ${PATH}.
        Parameters:
        prog - - program to find. For Windows, extensions "com" and "exe" can be omitted.
        Returns:
        - absolute location of the file on the file system or null if not found.
        Since:
        5.3