Programmatically locate file in Project? [message #330502] |
Wed, 30 July 2008 15:06  |
Eclipse User |
|
|
|
Given an IProject A and a file name B, is there any facility available
that can be used to determine whether file B is contained in project A?
My goal is to be able to determine whether a file belongs to a project
without doing a file search. Thanks.
- Ryan
|
|
|
Re: Programmatically locate file in Project? [message #330506 is a reply to message #330502] |
Wed, 30 July 2008 16:08   |
Eclipse User |
|
|
|
You can use a IResourceVisitor to browse thru the files in the project
and determine whether its available or not.
- Prakash
www.eclipse-tips.com
Ryan wrote:
> Given an IProject A and a file name B, is there any facility available
> that can be used to determine whether file B is contained in project A?
> My goal is to be able to determine whether a file belongs to a project
> without doing a file search. Thanks.
>
> - Ryan
>
|
|
|
|
Re: Programmatically locate file in Project? [message #330520 is a reply to message #330511] |
Thu, 31 July 2008 04:51  |
Eclipse User |
|
|
|
Yes. You should call project.accept(resourceVisitor); It will call the
visit method for every resource (assuming you have returning true for
its parent) Just check the java docs. It should help a lot
- Prakash
www.eclipse-tips.com
Ryan wrote:
> Thanks for the reply...this can work if all I have is a filename, like
> "test.h", and not a full path, like "/this/is/the/actual/location/test.h"?
>
> - Ryan
>
|
|
|
Powered by
FUDForum. Page generated in 0.03627 seconds