Any way to "reduce" a "jar-URL" to an actual path? [message #329359] |
Fri, 20 June 2008 21:18 |
Paul E. Keyser Messages: 878 Registered: July 2009 |
Senior Member |
|
|
R3.3; WinXP
We have a clunky old 3rd-party bit of code to which we must supply, in
the form of Windows full-paths, concatenated with ";", the actual
class-paths of all code and jars in some set. Thanks to an earlier post
("How to compute classpath from bundle?") by Jeff Pilgrim (whose email
address is no longer valid, alas), I have some code that will extract
from the Platform and the Bundle API a collection of URL's. So far so
good. Here is an example list:
jar:file:C:\<my-Eclipse-install>\eclipse\plugins\org.eclipse.ui_3.3.0.I20070614-0800.jar!/
jar:file:C:\<my-Eclipse-install>\eclipse\plugins\org.eclipse.swt_3.3.0.v3346.jar!/
jar:file:C:\<my-Eclipse-install> \eclipse\plugins\org.eclipse.jface_3.3.0.I20070606-0010.jar! /
jar:file:C:\<my-Eclipse-install> \eclipse\plugins\org.eclipse.core.commands_3.3.0.I20070605-0 010.jar!/
where I have printed the URL values using URL.toString().
The problem is -- how to convert such a "jar-URL" to a string? Our
clunky old 3rd-party code would want the list to look like this:
C:\<my-Eclipse-install>\eclipse\plugins\org.eclipse.ui_3.3.0.I20070614-0800.jar
C:\<my-Eclipse-install>\eclipse\plugins\org.eclipse.swt_3.3.0.v3346.jar
C:\<my-Eclipse-install>\eclipse\plugins\org.eclipse.jface_3.3.0.I20070606-0010.jar
C:\<my-Eclipse-install> \eclipse\plugins\org.eclipse.core.commands_3.3.0.I20070605-0 010.jar
Now, I can (and probably soon will have to) build my own little parser,
whose input would be URL.toString(), but that's of course fragile and
bug-prone.
I'd prefer it if there were a Platform of FileLocator method that took
as input one of the URL's and gave me the desired String as output. But
FileLocator.resolve(URL) simply does not work (it does other nice
things), and in fact the URL's above are *ALREADY* the output of
FileLocator.resolve(). I've also tried FileLocator.toFileURL(), which
seems to simply return the same URL, in this case.
So what is to be done?
TIA,
Paul
|
|
|
|
|
Re: Any way to "reduce" a "jar-URL" to an actual path? [message #329428 is a reply to message #329423] |
Mon, 23 June 2008 21:12 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Paul,
Isn't there a danger that the jar will be unzipped when that might not
be a desired side-effect? Of course you're right that if it has
platform: or bundleentry: you'd need a more general approach...
Paul Webster wrote:
> FileLocator.toFileURL(*) is the method that should be used in your
> case. It will convert any platform: URLs into file: URLs ... it might
> be that passing in the jar: URLs is confusing it, and they should be
> the platform: URLs
>
> PW
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03860 seconds