Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 265678 - Provide URIUtil for creating jar URIs
Summary: Provide URIUtil for creating jar URIs
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-20 12:02 EST by Andrew Niefer CLA
Modified: 2009-03-05 13:44 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Niefer CLA 2009-02-20 12:02:57 EST
See bug 265524, we can use a zip as a repo if we use a jar uri that looks like

jar:file:/C:/zipped/zipped.repo.zip!/

We should make a common utility method for building these URIs as there are likely many places we will want to be able to read them.



The implementation for bug 265524 does it by taking an existing URI:
URI uri = file.toURI();
if (file.isFile() && file.getName().endsWith(".zip")) { 
   try {
      uri = new URI("jar:" + uri.toString() + "!/"); 
   } catch (URISyntaxException e) {
     //problem
   }
}
Comment 1 John Arthorne CLA 2009-03-05 13:44:29 EST
Done. To make it more useful, the form of the method is toJarURI(URI,IPath), where the IPath specifies an entry in the jar file. If the path is null it returns the URI of the jar itself. To catch all the cases, the implementation ended up being more complex than the current code in PDE and UI. Susan and Andrew, be sure to switch over to using this method rather than assembling the URI yourself.