workspace.findFilesForLocation ? [message #326363] |
Mon, 17 March 2008 16:41  |
Eclipse User |
|
|
|
I need to find files by filename, eg given "foo.java" I want all files
in the workspace that have <path>/foo.java.
This looks hopeful:
public IFile[] findFilesForLocation(IPath location)
Returns the handles of all files that are mapped to the given path in
the local file system. Returns an empty array if there are none. The
path should be absolute; a relative path will be treated as absolute.
The path segments need not be valid names. The resulting files may not
currently exist.
But it does not work, and the phrase "relative path will be treated as
absolute" is not at all helpful. What does that mean? "Apples will be
treated as oranges": do I get orange juice or apple juice?
If this function does not lookup files like I want, can anyone suggest a
function that might to it? Otherwise I have to sweep the workstation for
file names and create/maintain a table I guess.
Thanks,
John.
|
|
|
|
Re: workspace.findFilesForLocation ? [message #326391 is a reply to message #326364] |
Tue, 18 March 2008 13:16  |
Eclipse User |
|
|
|
Thanks Ed for saving me some time. I implemented the visitor to build a
lookup table and hope my IResourceChangeListener will keep it up to date.
John.
Ed Merks wrote:
> John,
>
> It means that a path a/b will be treated as /a/b (or as c:/a/b on
> windows). You could use an IResourceVisitor if you want to visit all
> resource that match a particular path pattern. Of course a visitor and
> this method only search the workspace itself, not your whole file system.
>
>
> John J Barton wrote:
>> I need to find files by filename, eg given "foo.java" I want all files
>> in the workspace that have <path>/foo.java.
>>
>> This looks hopeful:
>> public IFile[] findFilesForLocation(IPath location)
>>
>> Returns the handles of all files that are mapped to the given path in
>> the local file system. Returns an empty array if there are none. The
>> path should be absolute; a relative path will be treated as absolute.
>> The path segments need not be valid names. The resulting files may not
>> currently exist.
>>
>> But it does not work, and the phrase "relative path will be treated as
>> absolute" is not at all helpful. What does that mean? "Apples will be
>> treated as oranges": do I get orange juice or apple juice?
>>
>> If this function does not lookup files like I want, can anyone suggest
>> a function that might to it? Otherwise I have to sweep the workstation
>> for file names and create/maintain a table I guess.
>>
>> Thanks,
>> John.
|
|
|
Powered by
FUDForum. Page generated in 0.02517 seconds