/** * Fix a path: * <ul> * <li>replace "{@code .}" by current directory</li> * <li>upcase the first character if it appears to be a drive letter</li> * <li>trim any trailing spaces</li> * <li>replace {@code \} by {@code /}</li> * <li>replace {@code //} by {@code /}</li> * <li>remove all trailing {@code /}</li> * </ul> */ private static String fixPathEntry(String path) { if (path == null) { return null; } if (path.equals(".")) { // $NON-NLS-1$ return System.getProperty("user.dir"); // $NON-NLS-1$ } String resultPath = path; if (path.length() > 3 && path.matches("[a-z]:\\\\.*")) { // lower-case drive letter? resultPath = path.substring(0, 1).toUpperCase(Locale.ROOT) + path.substring(1); } resultPath = resultPath.trim().replace('\\', '/'); // $NON-NLS-1$ // $NON-NLS-2$ resultPath = JOrphanUtils.substitute(resultPath, "//", "/"); // $NON-NLS-1$// $NON-NLS-2$ while (resultPath.endsWith("/")) { // $NON-NLS-1$ resultPath = resultPath.substring(0, resultPath.length() - 1); } return resultPath; }