/** * Concatenates the two strings and ensures the correct separator is used in the path */ public static String getOSUri(String directoryname, String filename) { String osDirName = getOSUri(directoryname); String osFileName = getOSUri(filename); return concatUri(osDirName, osFileName, File.separatorChar); }
protected void addFiles(java.io.File aDirectory, List aList) { String[] fileNames = aDirectory.list(); if (fileNames == null) return; for (int i = 0; i < fileNames.length; i++) { String fileName = ArchiveUtil.concatUri(aDirectory.getPath(), fileNames[i], SEPARATOR_CHAR); if (fileNames[i] == null || (IS_AIX && ".backup".equals(fileNames[i]))) //$NON-NLS-1$ continue; java.io.File aFile = new java.io.File(fileName); if (!aFile.exists()) continue; //This could occur on some windows machines, eg C:\pagefile.sys //throw new RuntimeException("Error scanning directory structure"); if (aFile.isDirectory() && !isArchive(getURIFrom(aFile))) { addDirectory(aFile, aList); } else { addFile(aFile, aList); } } }
protected File addCopyFileAddingPrefix(File aFile, String uriPrefix) throws DuplicateObjectException { String swizzledUri = aFile.getURI(); if (!swizzledUri.startsWith(uriPrefix)) { swizzledUri = ArchiveUtil.concatUri(uriPrefix, swizzledUri, '/'); } checkAddValid(swizzledUri); File copy = copy(aFile); copy.setURI(swizzledUri); getFiles().add(copy); return copy; }
protected File addCopyFileAddingPrefix(File aFile, String uriPrefix) throws DuplicateObjectException { String swizzledUri = aFile.getURI(); if (!swizzledUri.startsWith(uriPrefix)) { swizzledUri = ArchiveUtil.concatUri(uriPrefix, swizzledUri, '/'); } checkAddValid(swizzledUri); File copy = copy(aFile); copy.setURI(swizzledUri); getFiles().add(copy); return copy; }
protected File getFile(String name) { //search classes directory first, then war, then nested archives. //search classes directory String swizzledName = ArchiveUtil.concatUri(ArchiveConstants.WEBAPP_CLASSES_URI, name, '/'); try { return getWarFile().getFile(swizzledName); } catch (java.io.FileNotFoundException ex) { } //search war if running with compatibility if (allowLoadingFromWAR) { File file = getFileFromArchive(name); if (file != null) { return file; } } //search nested archives List children = getWarFile().getLibs(); for (int i = 0; i < children.size(); i++) { try { return ((Archive) children.get(i)).getFile(name); } catch (java.io.FileNotFoundException ex) { continue; } } //finally search jars in ear return getFileFromDependentJar(name); }