There is an example of creating linked resources in code.
-
IProject project = workspace.getProject("Project");//assume this exists
-
IFolder link = project.getFolder("Link");
-
IPath location = new Path("C:\TEMP\folder");
-
if (workspace.validateLinkLocation(location).isOK()) {
-
link.createLink(location, IResource.NONE, null);
-
} else {
-
//invalid location, throw an exception or warn user
-
}
This example will create a linked folder called "Link" that is located at "c:\temp\folder".
link.getFullPath() => "/Project/Link"
link.getLocation() => "c:\temp\folder"
link.getRawLocation() => "temp/folder"
link.isLinked() => "true"
IFile child = link.getFile("abc.txt");
child.create(...);
child.getFullPath() => "/Project/Link/abc.txt"
child.getLocation() => "c:\temp\folder\abc.txt"
child.getRawLocation() => "c:\temp\folder\abc.txt"
child.isLinked() => "false"
阅读(1797) | 评论(0) | 转发(0) |