MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / getResolvedPath

Method getResolvedPath

src/org/opensourcephysics/controls/XML.java:464–492  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 15

actionPerformedMethod · 0.95
saveMethod · 0.95
saveAsMethod · 0.95
saveTabSetAsMethod · 0.95
saveTabSetMethod · 0.95
saveTabsMethod · 0.95
isTabSetWritableMethod · 0.95
getAbsoluteTargetMethod · 0.95
getAbsoluteHTMLPathMethod · 0.95
LaunchableClassMapMethod · 0.95
loadAllClassesMethod · 0.95
showHelpMethod · 0.95

Calls 3

forwardSlashMethod · 0.95
lengthMethod · 0.80
equalsMethod · 0.65

Tested by 1

openLibraryResourceMethod · 0.76