Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 314982 - validateLinkLocationURI check for "path overlaps the location of the given project" is incorrect
Summary: validateLinkLocationURI check for "path overlaps the location of the given pr...
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Resources-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-29 10:30 EDT by Farokh Morshed CLA
Modified: 2010-06-01 09:59 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Farokh Morshed CLA 2010-05-29 10:30:33 EDT
Build Identifier:  M20090917-0800

method org.eclipse.core.internal.resources.LocationValidator.validateLinkLocationURI 

Has this code:


//test if the given path overlaps the location of the given project
testLocation = resource.getProject().getLocationURI();
if (testLocation != null && FileUtil.isPrefixOf(location, testLocation)) {
    message = NLS.bind(Messages.links_locationOverlapsProject, toString(location));
    return new ResourceStatus(IResourceStatus.INVALID_VALUE, resource.getFullPath(), message);
		}

Looks to me that the location and testLocation parameters in the call to FileUtil.isPrefixOf should be reversed!!


Reproducible: Always

Steps to Reproduce:
1. You can use the File | New | File dialog to create a link, and as target give a file in the open project itself.  The rules seem to not allow this, but the code allows it !
2.
3.
Comment 1 Serge Beauchamp CLA 2010-06-01 07:47:26 EDT
That condition looks fine to me, since if the location (for example "C:\foo\bar") is a prefix of the project location (say, "C:\foo\bar\project"), then that's an invalid location.

I'm not able to reproduce the issue with the steps you gave either.

I created a project in

/workspace/sample_p

I created a file in that project:

/workspace/sample_p/file.txt

Then I try to create a link resource file pointing to that location in project "sample_p".  It works fine (using 3.6 RC2).
Comment 2 Farokh Morshed CLA 2010-06-01 09:59:31 EDT
Sorry, I read the rules incorrectly.  I suppose you can have two workspace handles pointing to the same file on disk.  Why not.  It can happen in nested projects too.

Looks like the intent of the code I cited is to not let you create a directory link whose target is the project in which you are creating the handle in, or a directory above it.  That's a little weird, but so be it.

Thank you.