/** * When looking at the class path of this jar (from the manifest), some of the elements may have * a relative path, thus we need to determine the install location of this jar. If the absolute * path from which the archive was loaded, return the parent directory of that path; otherwise, * see if the containing archive has an absolute path; if neither work, default to the current * working directory */ public String getRootForRelativeDependentJars() { String path = null; Container theContainer = this; while (theContainer != null && path == null) { try { path = theContainer.getAbsolutePath(); } catch (FileNotFoundException ex) { //Ignore } theContainer = theContainer.getLoadingContainer(); } if (path == null) { path = System.getProperty("user.dir");//$NON-NLS-1$ if (path == null) //At this point what else can we do? return "";//$NON-NLS-1$ return new java.io.File(path).getAbsolutePath(); } return new java.io.File(path).getParentFile().getAbsolutePath(); }
/** * @see com.ibm.etools.commonarchive.File */ public java.io.InputStream getInputStream() throws java.io.FileNotFoundException, java.io.IOException { if (getLoadingContainer() != null || getLoadStrategy() == null || getLoadStrategy().isDirectory()) return super.getInputStream(); //This archive was copied in; this operation is not supported for // module files if (isModuleFile() || !getOptions().isSaveLibrariesAsFiles()) throw new IOException("Undefined state of nested archive"); //$NON-NLS-1$ //We have to find the absolute path of the original archive from which // this was copied, //if it is known List list = getFiles(); String absolutePath = null; for (int i = 0; i < list.size(); i++) { File aFile = (File) list.get(i); if (aFile.isArchive()) continue; absolutePath = aFile.getLoadingContainer().getAbsolutePath(); } return new FileInputStream(absolutePath); }