Example usage for org.apache.commons.vfs FileSystemManager createVirtualFileSystem

List of usage examples for org.apache.commons.vfs FileSystemManager createVirtualFileSystem

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileSystemManager createVirtualFileSystem.

Prototype

public FileObject createVirtualFileSystem(FileObject rootFile) throws FileSystemException;

Source Link

Document

Creates a virtual file system.

Usage

From source file:org.codehaus.mojo.unix.core.FsFileCollector.java

public FsFileCollector(FileObject fsRoot) throws FileSystemException {
    this.fsRoot = fsRoot;
    FileSystemManager fileSystemManager = fsRoot.getFileSystem().getFileSystemManager();
    FileObject root = fileSystemManager.createVirtualFileSystem(fsRoot);
    root.createFolder();/* w  w w  . j av a 2s .c o m*/
    this.root = root;
}

From source file:org.efaps.webdav4vfs.test.AbstractDavTestCase.java

@BeforeMethod()
public void setUp() throws Exception {
    FileSystemManager fsm = VFS.getManager();
    FileObject fsRoot = fsm.createVirtualFileSystem(fsm.resolveFile("ram:/"));
    this.aFile = fsRoot.resolveFile("/file.txt");
    this.aFile.delete();
    this.aFile.createFile();
    this.aDirectory = fsRoot.resolveFile("/folder");
    this.aDirectory.delete();
    this.aDirectory.createFolder();
}

From source file:org.geoserver.importer.VFSWorker.java

/**
 * Extracts the archive file {@code archiveFile} to {@code targetFolder}; both shall previously
 * exist./*from w  w  w  . ja  v a  2s.co m*/
 */
public void extractTo(File archiveFile, File targetFolder) throws IOException {

    FileSystemManager manager = VFS.getManager();
    String sourceURI = resolveArchiveURI(archiveFile);
    // String targetURI = resolveArchiveURI(targetFolder);
    FileObject source = manager.resolveFile(sourceURI);
    if (manager.canCreateFileSystem(source)) {
        source = manager.createFileSystem(source);
    }
    FileObject target = manager.createVirtualFileSystem(manager.resolveFile(targetFolder.getAbsolutePath()));

    FileSelector selector = new AllFileSelector() {
        @Override
        public boolean includeFile(FileSelectInfo fileInfo) {
            LOGGER.fine("Uncompressing " + fileInfo.getFile().getName().getFriendlyURI());
            return true;
        }
    };
    target.copyFrom(source, selector);
}