* @param absolute the File to convert to relative path
* @return a File with a path that is relative to the user's directory
* @exception Exception if the path cannot be constructed
*/
public static File convertToRelativePath(File absolute) throws Exception {
File result;
String fileStr;
result = null;
// if we're running windows, it could be Cygwin
if (File.separator.equals("\\")) {
// Cygwin doesn't like upper case drives -> try lower case drive
try {
fileStr = absolute.getPath();
fileStr = fileStr.substring(0, 1).toLowerCase()
+ fileStr.substring(1);
result = createRelativePath(new File(fileStr));
}
catch (Exception e) {
// no luck with Cygwin workaround, convert it like it is
result = createRelativePath(absolute);
}