List of usage examples for org.apache.commons.vfs FileObject resolveFile
public FileObject resolveFile(String name, NameScope scope) throws FileSystemException;
From source file:com.pongasoft.util.io.IOUtils.java
/** * Returns a child of the provided file object designated by the uri path * * @param uriPath the path to the child/*from w ww . ja v a 2 s. co m*/ * @param fileObject the file object (root) * @return the new file object * @throws IOException if there is something wrong */ public static FileObject resolveFile(FileObject fileObject, URIPath uriPath) throws IOException { String fullPath = uriPath.getFullPath(); if ("".equals(fullPath) || "/".equals(fullPath)) return fileObject; else return fileObject.resolveFile(fullPath, NameScope.DESCENDENT); }
From source file:com.pongasoft.kiwidoc.builder.JSONContentHandler.java
private FileObject getContentFile(FileObject contentFile) throws FileSystemException { return contentFile.resolveFile(CONTENT_FILENAME, NameScope.CHILD); }
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.// w w w . ja v a 2 s . c o m * * @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(); } }