/** * Protected method for simplyfied addinng of mapped files * * @param file file to add * @param baseDir base directory for file */ protected void addMappedFile(File file, File baseDir) { if (file.isFile()) { if (baseDir == null) { baseDir = file.getParentFile(); } MappedFile mappedFile = new MappedFile(); mappedFile.setFrom(file); String filename = file.getName(); String[] names = getMapper().mapFileName(filename); // we don't use original filename if no mapping is available if (names == null || names.length == 0) { return; } File newFile = new File(file.getParent() + System.getProperty("file.separator") + names[0]); if (getDestDir() != null) { try { newFile = new File( newFile .getCanonicalPath() .replace(baseDir.getCanonicalPath(), getDestDir().getCanonicalPath())); } catch (IOException ex) { log("Couldn't map file", ex, Project.MSG_WARN); return; } } mappedFile.setTo(newFile); mappedFiles.add(mappedFile); } else if (file.isDirectory()) { if (baseDir == null) { baseDir = file; } DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(file); ds.scan(); for (String fileName : ds.getIncludedFiles()) { addMappedFile(new File(file + System.getProperty("file.separator") + fileName), baseDir); } } }
/** * Add resource collection * * @param rc resource collection to add */ public void add(ResourceCollection rc) { resources.add(rc); }