Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Getting the full path to files in subfolders of a plugin?
Getting the full path to files in subfolders of a plugin? [message #75868] Mon, 16 June 2003 18:15 Go to next message
Eclipse UserFriend
Originally posted by: michael.renz.web.de

Hi,
I am looking for a smarter way to do the following:
I want to have some xml-schemas in a special subfolder of my plugin.

The structure might be like this:

c:\eclipse
-plugins
-MyPlugin_1.0.0
-xmlSchemas
-schema1.xsd
-schema2.xsd

As far as I know, I need to provide the full path to the schemas for my
xml-parser
to handle the schemas. So I tried to get it as follows:

String path =
MyPlugin.getDefault().getDescriptor().getInstallURL().getPat h();
//returns "/plugin/MyPlugin_1.0.0/" I don't know why it is "plugin" instead
of "plugins"...
IPath plPath = Platform.getLocation();
//returns something like "C:/eclipse/runtime-workspace"
plPath = plPath.removeLastSegments(1);
path = plPath.toString().concat(path + "xmlSchemas/schema1.xsd");
File schemaPath = new Path(path).toFile(); //Just to convert "/" to "\"
path = schemaPath.getPath();

The result will be like this:
"C:\eclipse\plugin\MyPlugin_1.0.0\xmlSchemas\schema1.xsd".
I still will have to change "plugin" to "plugins" but anyhow all this is
kind of cumbersome and on top
of it, I will have to create this folder structure in eclipse/plugins of my
development environment.
It is not working when I just have the schemas in my project's workspace in
a xmlSchemas folder.

Thanks for any smart ideas.
Michael
Re: Getting the full path to files in subfolders of a plugin? [message #75941 is a reply to message #75868] Mon, 16 June 2003 23:40 Go to previous message
Eclipse UserFriend
Michael Renz wrote:
> Hi,
> I am looking for a smarter way to do the following:
> I want to have some xml-schemas in a special subfolder of my plugin.
>
> The structure might be like this:
>
> c:\eclipse
> -plugins
> -MyPlugin_1.0.0
> -xmlSchemas
> -schema1.xsd
> -schema2.xsd
>
> As far as I know, I need to provide the full path to the schemas for my
> xml-parser
> to handle the schemas. So I tried to get it as follows:
>
> String path =
> MyPlugin.getDefault().getDescriptor().getInstallURL().getPat h();
> //returns "/plugin/MyPlugin_1.0.0/" I don't know why it is "plugin" instead
> of "plugins"...
> IPath plPath = Platform.getLocation();
> //returns something like "C:/eclipse/runtime-workspace"
> plPath = plPath.removeLastSegments(1);
> path = plPath.toString().concat(path + "xmlSchemas/schema1.xsd");
> File schemaPath = new Path(path).toFile(); //Just to convert "/" to "\"
> path = schemaPath.getPath();
>
> The result will be like this:
> "C:\eclipse\plugin\MyPlugin_1.0.0\xmlSchemas\schema1.xsd".
> I still will have to change "plugin" to "plugins" but anyhow all this is
> kind of cumbersome and on top
> of it, I will have to create this folder structure in eclipse/plugins of my
> development environment.
> It is not working when I just have the schemas in my project's workspace in
> a xmlSchemas folder.

You are making many incorrect assumptions. First, you need to understand
the return value of IPluginDescriptor.getInstallURL(). Read this:

http://eclipsewiki.swiki.net/114#platformurl

Also, you are assuming that the user's workspace is inside their
eclipse/ directory, which is likely to be untrue.

For the correct way to handle this, read the archives, specifically this
post:

http://dev.eclipse.org/newslists/news.eclipse.tools/msg00456 .html

Jeff
Previous Topic:A question about cooperation between plugins...
Next Topic:-> Java SDK 1.5 and generics
Goto Forum:
  


Current Time: Sat May 10 12:05:58 EDT 2025

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

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

Back to the top