public static String getRelativePath(File basePath, File path) {\r
File exactBase = getExactFile(basePath);\r
File exactPath = getExactFile(path);\r
- if (exactPath.getPath().startsWith(exactBase.getPath())) {\r
+ if (path.getAbsolutePath().startsWith(basePath.getAbsolutePath())) {\r
+ // absolute base-path match\r
+ return StringUtils.getRelativePath(basePath.getAbsolutePath(), path.getAbsolutePath());\r
+ } else if (exactPath.getPath().startsWith(exactBase.getPath())) {\r
// canonical base-path match\r
return StringUtils.getRelativePath(exactBase.getPath(), exactPath.getPath());\r
} else if (exactPath.getPath().startsWith(basePath.getAbsolutePath())) {\r
} else if (path.getAbsolutePath().startsWith(exactBase.getPath())) {\r
// mixed path match\r
return StringUtils.getRelativePath(exactBase.getPath(), path.getAbsolutePath());\r
- } else if (path.getAbsolutePath().startsWith(basePath.getAbsolutePath())) {\r
- // absolute base-path match\r
- return StringUtils.getRelativePath(basePath.getAbsolutePath(), path.getAbsolutePath());\r
}\r
// no relative relationship\r
return null;\r