List of usage examples for org.apache.commons.vfs.impl DefaultFileSystemManager getReplicator
public FileReplicator getReplicator() throws FileSystemException
From source file:com.pongasoft.kiwidoc.builder.doclet.SourceCodeParser.java
/** * Parses the sources using a doclet. It is ok to provide a big number of files, since it will * automatically be split in chunks./*from w w w . j a v a 2 s . c om*/ * * @param library the library to store the results * @param sources the sources * @return the number of processed files * @throws IOException if there is an issue reading the files */ public int parseSources(LibraryModelBuilder library, FileObject sources, String overviewFilename, FileObject javadoc, Collection<FileObject> dependencies) throws IOException, InternalException { DefaultFileSystemManager dfs = new DefaultFileSystemManager(); dfs.addProvider("file", new DefaultLocalFileProvider()); dfs.setReplicator(new DefaultFileReplicator(IOUtils.createTempDirectory("SourceCodeParser", ""))); dfs.init(); try { File localSources = dfs.getReplicator().replicateFile(sources, SourcesSelector.INSTANCE); sources = dfs.toFileObject(localSources); FileObject[] allSources = sources.findFiles(JavaSelector.INSTANCE); if (allSources == null || allSources.length == 0) return 0; List<String> sourcePath = new ArrayList<String>(); for (FileObject sourceFile : allSources) { // if(javadoc != null) // { // String name = sources.getName().getRelativeName(sourceFile.getName()); // name = name.substring(0, name.length() - JAVA_EXTENSION.length()); // name += HTML_EXTENSION; // if(javadoc.resolveFile(name, NameScope.DESCENDENT).exists()) // sourcePath.add(sourceFile.getName().getPath()); // } // else // { // sourcePath.add(sourceFile.getName().getPath()); // } sourcePath.add(sourceFile.getName().getPath()); } List<String> deps = new ArrayList<String>(); if (dependencies != null) { for (FileObject dependency : dependencies) { if (dependency.exists()) { File localDependency = dfs.getReplicator().replicateFile(dependency, DependenciesSelector.INSTANCE); deps.add(localDependency.getCanonicalPath()); } } } FileObject overviewFile = sources.resolveFile(overviewFilename, NameScope.CHILD); String overviewPath = null; if (overviewFile.exists()) overviewPath = overviewFile.getName().getPath(); parseSources(library, overviewPath, sourcePath, deps); return sourcePath.size(); } finally { dfs.close(); } }