Path baseIPath = new Path(basePath);
IResource baseResource = FileBuffers.getWorkspaceFileAtLocation(baseIPath);
if (baseResource == null) {
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
// Try the base path as a folder first
if (baseIPath.segmentCount() > 1) {
baseResource = workspaceRoot.getFolder(baseIPath);
}
// If not a folder, then try base path as a file
if (baseResource != null && !baseResource.exists() && baseIPath.segmentCount() > 1) {
baseResource = workspaceRoot.getFile(baseIPath);
}
if (baseResource == null && baseIPath.segmentCount() == 1) {
baseResource = workspaceRoot.getProject(baseIPath.segment(0));
}
}
if (baseResource == null) {
/*