|
Thanks Tom,
Yes this works. :)
FileLocator.resolve(Platform.getBundle("UCSIM").getResource("Profile/Profile.uml2"));
gives me the exact path of the
resource, however I am not sure why it adds '/' in the beginning of the
path.
Regards Praveen.
Hi,
why
don't you simple call ----------8<---------- InputStream in =
Platform.getBundle("com.my.plugin").getResource("my.file").open(); ----------8<----------
Tom
Praveen
schrieb: > Hi John, > > Thank you for your reply. I am
trying to use the API as you suggested, but am not able to get a path. In fact
the getProject returns me a project even when the project does not exist.
> > I just realized that I should not be accessing the resource
as a file path, because if the plugin is deployed as a jar, then the jar would
need to be extracted to a temp location for the absolute path to be
valid. > > Is there a better way to access a resource contained
in a plugin folder? > > Regards Praveen. >
"John J. Barton" <johnjbarton@xxxxxxxxxxxxxxx>
wrote in message news:ekth5d$skj$1@xxxxxxxxxxxxxxxxx... >
Maybe this will give you some hints as to which API to look into: >
> IProject project = >
ResourcesPlugin.getWorkspace().getRoot().getProject(best_project_match); >
> IPath as_specific_as_possible =
source_path; > if (project.exists())
{ > iseg++; // skip project
name > IPath resourcePath =
source_path.removeFirstSegments(iseg); >
IResource resource =
project.findMember(resourcePath); >
as_specific_as_possible =
resource.getLocation(); > if
(as_specific_as_possible == null) { >
as_specific_as_possible = path; // someone
lied > } > } // else not in
workspace > > If you really want a URL, then try
something like >
path.toFile().toURI().toURL(); > > Praveen
wrote: > > Hi, > >
> > I am writing a plugin and need to access a file
within one of the folder. > > >
> I tried using URL
u=this.getClass().getResource("/Profile/Profile.uml2"); >
> > > But this returns a path of the eclipse
installation. Is there any other > > API which can
return the path of the file? > >
> > Thanks Praveen.
|