Resolves the name of a file specified relative to a base path. @param relativePath the relative file name @param base the absolute base path @return the resolved file name with forward slashes
(String relativePath, String base)
| 462 | * @return the resolved file name with forward slashes |
| 463 | */ |
| 464 | public static String getResolvedPath(String relativePath, String base) { |
| 465 | if (base != null && base.endsWith("/")) //$NON-NLS-1$ |
| 466 | base = base.substring(0, base.length() - 1); |
| 467 | relativePath = forwardSlash(relativePath); |
| 468 | // return relativePath if it is really absolute |
| 469 | if (relativePath.startsWith("/") || (relativePath.indexOf(":/") >= 0)) { //$NON-NLS-1$ //$NON-NLS-2$ |
| 470 | return relativePath; |
| 471 | } |
| 472 | base = forwardSlash(base); |
| 473 | while (relativePath.startsWith("../") && !base.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$ |
| 474 | if (base.indexOf("/") == -1) { //$NON-NLS-1$ |
| 475 | base = "/" + base; //$NON-NLS-1$ |
| 476 | } |
| 477 | relativePath = relativePath.substring(3); |
| 478 | base = base.substring(0, base.lastIndexOf("/")); //$NON-NLS-1$ |
| 479 | } |
| 480 | if (relativePath.startsWith("./")) //$NON-NLS-1$ |
| 481 | relativePath = relativePath.substring(2); |
| 482 | if (relativePath.equals(".")) //$NON-NLS-1$ |
| 483 | relativePath = ""; //$NON-NLS-1$ |
| 484 | if (base.equals("")) { //$NON-NLS-1$ |
| 485 | return relativePath; |
| 486 | } |
| 487 | // BH 2020.11.15 "&" check here is for https DL library calls |
| 488 | if (base.endsWith("/") || relativePath.startsWith("&")) { //$NON-NLS-1$ $NON-NLS-2$ |
| 489 | return base + relativePath; |
| 490 | } |
| 491 | return base + "/" + relativePath; //$NON-NLS-1$ |
| 492 | } |
| 493 | |
| 494 | /** |
| 495 | * Creates any missing folders in the specified path. |