/** * Appends the specified FileObjects to the list of FileObjects to search for classes and resources. * * @param manager The FileSystemManager. * @param files the FileObjects to append to the search path. * @throws FileSystemException if an error occurs. */ private void addFileObjects(final FileSystemManager manager, final FileObject[] files) throws FileSystemException { for (FileObject file : files) { if (!file.exists()) { // Does not exist - skip continue; } // TODO - use federation instead if (manager.canCreateFileSystem(file)) { // Use contents of the file file = manager.createFileSystem(file); } resources.add(file); } }
/** * Appends the specified FileObjects to the list of FileObjects to search for classes and resources. * * @param manager The FileSystemManager. * @param files the FileObjects to append to the search path. * @throws FileSystemException if an error occurs. */ private void addFileObjects(final FileSystemManager manager, final FileObject[] files) throws FileSystemException { for (FileObject file : files) { if (!file.exists()) { // Does not exist - skip continue; } // TODO - use federation instead if (manager.canCreateFileSystem(file)) { // Use contents of the file file = manager.createFileSystem(file); } resources.add(file); } }
/** * Appends the specified FileObjects to the list of FileObjects to search for classes and resources. * * @param manager The FileSystemManager. * @param files the FileObjects to append to the search path. * @throws FileSystemException if an error occurs. */ private void addFileObjects(final FileSystemManager manager, final FileObject[] files) throws FileSystemException { for (FileObject file : files) { if (!file.exists()) { // Does not exist - skip continue; } // TODO - use federation instead if (manager.canCreateFileSystem(file)) { // Use contents of the file file = manager.createFileSystem(file); } resources.add(file); } }
File zipFile = ...; File outputDir = ...; FileSystemManager fsm = VFS.getManager(); URI zip = zipFile.toURI(); FileObject packFileObject = fsm.resolveFile(packLocation.toString()); FileObject to = fsm.toFileObject(destDir); FileObject zipFS; try { zipFS = fsm.createFileSystem(packFileObject); fsm.toFileObject(outputDir).copyFrom(zipFS, new AllFileSelector()); } finally { zipFS.close(); }
fileSystem = fsManager.createFileSystem(resolvedFile); } else { fileSystem = resolvedFile;
/** * Will extract a .zip or .tar archive to the specified outFile location * * @param inFile * @param outFile * @return */ private static ResourceOperationStatus extractArchive(File inFile, File outFile) { try { URI inFileUri = inFile.toURI(); logger.info("Extracting archive: {}", inFileUri); FileSystemManager fileSystemManager = VFS.getManager(); FileObject tarFile = fileSystemManager.resolveFile(inFileUri.toString()); try { FileObject zipFileSystem = fileSystemManager.createFileSystem(tarFile); try { fileSystemManager.toFileObject(outFile).copyFrom(zipFileSystem, new AllFileSelector()); } finally { zipFileSystem.close(); } } finally { tarFile.close(); } return ResourceOperationStatus.SUCCESS; } catch (FileSystemException ex) { logger.error(null, ex); } return ResourceOperationStatus.FAILURE; }
/** * Returns the base folder for tests. */ @Override public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { // Locate the base Tar file final String tarFilePath = AbstractVfsTestCase.getTestResource("nested.tgz").getAbsolutePath(); final String uri = "tgz:file:" + tarFilePath + "!/test.tgz"; final FileObject tarFile = manager.resolveFile(uri); // Now build the nested file system final FileObject nestedFS = manager.createFileSystem(tarFile); return nestedFS.resolveFile("/"); } }
/** * Returns the base folder for tests. */ @Override public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { // Locate the base Zip file final String zipFilePath = AbstractVfsTestCase.getTestResource("nested.zip").getAbsolutePath(); final String uri = "zip:file:" + zipFilePath + "!/test.zip"; final FileObject zipFile = manager.resolveFile(uri); // Now build the nested file system final FileObject nestedFS = manager.createFileSystem(zipFile); return nestedFS.resolveFile("/"); } }
/** * Returns the base folder for tests. */ @Override public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { // Locate the Jar file final File outerFile = AbstractVfsTestCase.getTestResource("nested.jar"); final String uri = "jar:file:" + outerFile.getAbsolutePath() + "!/test.jar"; final FileObject jarFile = manager.resolveFile(uri); // Now build the nested file system final FileObject nestedFS = manager.createFileSystem(jarFile); return nestedFS.resolveFile("/"); } }
/** * Returns the base folder for tests. */ @Override public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { // Locate the base Tar file final String tarFilePath = AbstractVfsTestCase.getTestResource("nested.tgz").getAbsolutePath(); final String uri = "tgz:file:" + tarFilePath + "!/test.tgz"; final FileObject tarFile = manager.resolveFile(uri); // Now build the nested file system final FileObject nestedFS = manager.createFileSystem(tarFile); return nestedFS.resolveFile("/"); } }
/** * Returns the base folder for tests. */ @Override public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { // Locate the Jar file final File outerFile = AbstractVfsTestCase.getTestResource("nested.jar"); final String uri = "jar:file:" + outerFile.getAbsolutePath() + "!/test.jar"; final FileObject jarFile = manager.resolveFile(uri); // Now build the nested file system final FileObject nestedFS = manager.createFileSystem(jarFile); return nestedFS.resolveFile("/"); } }
/** * Returns the base folder for tests. */ @Override public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { // Locate the base Tar file final String tarFilePath = AbstractVfsTestCase.getTestResource("nested.tbz2").getAbsolutePath(); final String uri = "tbz2:file:" + tarFilePath + "!/test.tbz2"; final FileObject tarFile = manager.resolveFile(uri); // Now build the nested file system final FileObject nestedFS = manager.createFileSystem(tarFile); return nestedFS.resolveFile("/"); } }
/** * Returns the base folder for tests. */ @Override public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { // Locate the base Tar file final String tarFilePath = AbstractVfsTestCase.getTestResource("nested.tbz2").getAbsolutePath(); final String uri = "tbz2:file:" + tarFilePath + "!/test.tbz2"; final FileObject tarFile = manager.resolveFile(uri); // Now build the nested file system final FileObject nestedFS = manager.createFileSystem(tarFile); return nestedFS.resolveFile("/"); } }
/** * Returns the base folder for tests. */ @Override public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { // Locate the base Zip file final String zipFilePath = AbstractVfsTestCase.getTestResource("nested.zip").getAbsolutePath(); final String uri = "zip:file:" + zipFilePath + "!/test.zip"; final FileObject zipFile = manager.resolveFile(uri); // Now build the nested file system final FileObject nestedFS = manager.createFileSystem(zipFile); return nestedFS.resolveFile("/"); } }
/** * Extracts the archive file {@code archiveFile} to {@code targetFolder}; both shall previously * exist. */ 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); source.close(); target.close(); manager.closeFileSystem(source.getFileSystem()); }
/** * Returns the base folder for tests. */ @Override public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { // We test with non-empty FS options to make sure they are propagated final FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, new StaticUserAuthenticator("domain", null, null)); // Locate the base Tar file final String tarFilePath = AbstractVfsTestCase.getTestResource("nested.tar").getAbsolutePath(); // Now build the nested file system final String uri = "tar:file:" + tarFilePath + "!/test.tar"; final FileObject tarFile = manager.resolveFile(uri, opts); final FileObject nestedFS = manager.createFileSystem(tarFile); return nestedFS.resolveFile("/"); } }
/** * Returns the base folder for tests. */ @Override public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { // We test with non-empty FS options to make sure they are propagated final FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, new StaticUserAuthenticator("domain", null, null)); // Locate the base Tar file final String tarFilePath = AbstractVfsTestCase.getTestResource("nested.tar").getAbsolutePath(); // Now build the nested file system final String uri = "tar:file:" + tarFilePath + "!/test.tar"; final FileObject tarFile = manager.resolveFile(uri, opts); final FileObject nestedFS = manager.createFileSystem(tarFile); return nestedFS.resolveFile("/"); } }
private void check(final FileSystemManager manager, FileObject file) throws FileSystemException { assertNotNull(file); assertTrue(file.exists()); assertSame(FileType.FILE, file.getType()); assertTrue(file.isFile()); // Expand it file = manager.createFileSystem(file); assertNotNull(file); assertTrue(file.exists()); assertSame(FileType.FOLDER, file.getType()); assertTrue(file.isFolder()); }
private void check(final FileSystemManager manager, FileObject file) throws FileSystemException { assertNotNull(file); assertTrue(file.exists()); assertSame(FileType.FILE, file.getType()); assertTrue(file.isFile()); // Expand it file = manager.createFileSystem(file); assertNotNull(file); assertTrue(file.exists()); assertSame(FileType.FOLDER, file.getType()); assertTrue(file.isFolder()); }