Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 316650

Summary: PathUtil doesn't make paths relative correctly across volumes
Product: [Eclipse Project] Equinox Reporter: John Arthorne <john.arthorne>
Component: p2Assignee: John Arthorne <john.arthorne>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: dj.houghton, jcayne, paulslau, tjwatson
Version: 3.6   
Target Milestone: 3.6.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Fix and regression test v01 none

Description John Arthorne CLA 2010-06-11 15:57:35 EDT
Build: 3.6

PathUtil.makeRelative("file:/a/b", new URL("file:/d:/a/x))

Returns: "file:../b", but since the device is different it should return "file:/c:/a/b".
Comment 1 John Arthorne CLA 2010-06-11 15:59:35 EDT
Created attachment 171764 [details]
Fix and regression test v01
Comment 2 John Arthorne CLA 2010-06-11 16:02:27 EDT
I noticed while testing this that PathUtil has all kinds of crazy behaviour. It can return a mixture of / and \ path separators on Windows. It also creates bad relative URLs such as file:a/b/ (relative URL shouldn't have a device). In any case I've opted not to change anything else in this patch except the cross-volume bug. This class is generally only used in backwards compatibility situations like reading/writing plaform.xml, and most of p2 uses the much more consistent URIUtil methods.
Comment 3 John Arthorne CLA 2010-06-11 16:30:24 EDT
Sorry, that first line should read:

PathUtil.makeRelative("file:/c:/a/b", new URL("file:/d:/a/x))

Returns: "file:../b" but should return "file:/c:/a/b".
Comment 4 John Arthorne CLA 2010-06-22 10:47:32 EDT
Fix released for 3.6.1 and 3.7
Comment 5 John Arthorne CLA 2010-06-23 16:03:58 EDT
*** Bug 311387 has been marked as a duplicate of this bug. ***