Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » workspace.findFilesForLocation ?
workspace.findFilesForLocation ? [message #326363] Mon, 17 March 2008 20:41 Go to next message
John J. Barton is currently offline John J. BartonFriend
Messages: 311
Registered: July 2009
Senior Member
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 #326364 is a reply to message #326363] Mon, 17 March 2008 21:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

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.
Re: workspace.findFilesForLocation ? [message #326391 is a reply to message #326364] Tue, 18 March 2008 17:16 Go to previous message
John J. Barton is currently offline John J. BartonFriend
Messages: 311
Registered: July 2009
Senior Member
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.
Previous Topic:Synchronously delete project
Next Topic:How to connect the debug console to my debugger ???
Goto Forum:
  


Current Time: Sat Jul 27 16:25:29 GMT 2024

Powered by FUDForum. Page generated in 0.03364 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top