public static IPath getFilterPath ( String filePath , IProject project ) { IPath path = new Path ( filePath ) ; if ( path . isAbsolute ( ) ) { return path ; } if ( project != null ) { // try first project relative location IPath newPath = project . getLocation ( ) . append ( path ) ; if ( newPath . toFile ( ) . exists ( ) ) { return newPath ; } } // try to resolve relative to workspace (if we use workspace properties // for project) IPath wspLocation = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getLocation ( ) ; IPath newPath = wspLocation . append ( path ) ; if ( newPath . toFile ( ) . exists ( ) ) { return newPath ; } // something which we have no idea what it can be (or missing/wrong file // path) return path ; }
Checks the given path and convert it to absolute path if it is specified relative to the given project or workspace