protected void browseForFileInputPath() { try { String path = space.environmentSubstitute( wPath.getText() ); VfsFileChooserDialog fileChooserDialog; String fileName; if ( path == null || path.length() == 0 ) { fileChooserDialog = getVfsFileChooserDialog( null, null ); fileName = selectedVFSScheme.scheme + "://"; } else { FileObject initialFile = getInitialFile( wPath.getText() ); FileObject rootFile = initialFile.getFileSystem().getRoot(); fileChooserDialog = getVfsFileChooserDialog( rootFile, initialFile ); fileName = null; } FileObject selectedFile = fileChooserDialog.open( getParent().getShell(), null, selectedVFSScheme.scheme, true, fileName, FILES_FILTERS, fileFilterNames, true, VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE_OR_DIRECTORY, true, true ); if ( selectedFile != null ) { String filePath = selectedFile.getURL().toString(); if ( !DEFAULT_LOCAL_PATH.equals( filePath ) ) { wPath.setText( filePath ); updateLocation(); } } } catch ( KettleFileException | FileSystemException ex ) { log.logError( ex.getMessage() ); } }
try { initialFile = KettleVFS.getFileObject( getLastFileOpened() ); rootFile = KettleVFS.getFileObject( getLastFileOpened() ).getFileSystem().getRoot(); } catch ( Exception e ) { MessageBox messageDialog = new MessageBox( shell, SWT.ICON_ERROR | SWT.OK );
public void openFileVFSFile() { FileObject initialFile; FileObject rootFile; try { initialFile = KettleVFS.getFileObject( getLastFileOpened() ); rootFile = initialFile.getFileSystem().getRoot(); } catch ( Exception e ) { String message = Const.getStackTracker( e ); new ErrorDialog( shell, BaseMessages.getString( PKG, "Spoon.Error" ), message, e ); return; } FileObject selectedFile = getVfsFileChooserDialog( rootFile, initialFile ).open( shell, null, Const.STRING_TRANS_AND_JOB_FILTER_EXT, Const.getTransformationAndJobFilterNames(), VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE ); if ( selectedFile != null ) { setLastFileOpened( selectedFile.getName().getFriendlyURI() ); openFile( selectedFile.getName().getFriendlyURI(), rep != null ); } }
/** * Returns the root filesystem of a given file * * @param fileObject A file * @return the root filesystem of a given file */ public static FileObject createFileSystemRoot(FileObject fileObject) { try { return fileObject.getFileSystem().getRoot(); } catch (FileSystemException ex) { return null; } }
/** * Returns the root filesystem of a given file * @param fileObject A file * @return the root filesystem of a given file */ public static FileObject createFileSystemRoot(FileObject fileObject) { try { return fileObject.getFileSystem().getRoot(); } catch (FileSystemException ex) { return null; } }
/** * Returns the root file system of a file representation * * @param fileObject A file abstraction * @return the root file system of a file representation */ public static FileObject getRootFileSystem(FileObject fileObject) { try { if ((fileObject == null) || !fileObject.exists()) { return null; } return fileObject.getFileSystem().getRoot(); } catch (FileSystemException ex) { return null; } }
/** * Tests root of file system exists. */ public void testRootAPI() throws FileSystemException { if (!this.getProviderConfig().isFileSystemRootAccessible()) { return; } testRoot(getFileSystem().getRoot()); }
/** * Tests root of file system exists. */ public void testRootAPI() throws FileSystemException { if (!this.getProviderConfig().isFileSystemRootAccessible()) { return; } testRoot(getFileSystem().getRoot()); }
/** * Tests root of file system exists. */ public void testRootAPI() throws FileSystemException { if (!this.getProviderConfig().isFileSystemRootAccessible()) { return; } testRoot(getFileSystem().getRoot()); }
/** * Tests url. */ public void testURL() throws Exception { final FileObject file = getReadFolder().resolveFile("some-dir/"); final URL url = file.getURL(); assertEquals(file.getName().getURI(), url.toExternalForm()); final URL parentURL; try { parentURL = new URL(url, ".."); } catch (final MalformedURLException e) { throw e; } assertEquals(file.getParent().getURL(), parentURL); final URL rootURL = new URL(url, "/"); assertEquals(file.getFileSystem().getRoot().getURL(), rootURL); }
/** * Tests url. */ public void testURL() throws Exception { final FileObject file = getReadFolder().resolveFile("some-dir/"); final URL url = file.getURL(); assertEquals(file.getName().getURI(), url.toExternalForm()); final URL parentURL; try { parentURL = new URL(url, ".."); } catch (final MalformedURLException e) { throw e; } assertEquals(file.getParent().getURL(), parentURL); final URL rootURL = new URL(url, "/"); assertEquals(file.getFileSystem().getRoot().getURL(), rootURL); }
/** * Tests the root file name. */ public void testRootFileName() throws Exception { // Locate the root file final FileName rootName = getReadFolder().getFileSystem().getRoot().getName(); // Test that the root path is "/" assertEquals("root path", "/", rootName.getPath()); // Test that the root basname is "" assertEquals("root base name", "", rootName.getBaseName()); // Test that the root name has no parent assertNull("root parent", rootName.getParent()); }
/** * Tests the root file name. */ public void testRootFileName() throws Exception { // Locate the root file final FileName rootName = getReadFolder().getFileSystem().getRoot().getName(); // Test that the root path is "/" assertEquals("root path", "/", rootName.getPath()); // Test that the root basname is "" assertEquals("root base name", "", rootName.getBaseName()); // Test that the root name has no parent assertNull("root parent", rootName.getParent()); }
/** * Tests the root file name. */ public void testRootFileName() throws Exception { // Locate the root file final FileName rootName = getReadFolder().getFileSystem().getRoot().getName(); // Test that the root path is "/" assertEquals("root path", "/", rootName.getPath()); // Test that the root basname is "" assertEquals("root base name", "", rootName.getBaseName()); // Test that the root name has no parent assertNull("root parent", rootName.getParent()); }
/** * Tests resolution of absolute names. */ public void testAbsoluteNames() throws Exception { // Test against the base folder FileName name = getReadFolder().getName(); checkAbsoluteNames(name); // Test against the root name = getReadFolder().getFileSystem().getRoot().getName(); checkAbsoluteNames(name); // Test against some unknown file name = getManager().resolveName(name, "a/b/unknown"); checkAbsoluteNames(name); }
/** * Tests resolution of absolute names. */ public void testAbsoluteNames() throws Exception { // Test against the base folder FileName name = getReadFolder().getName(); checkAbsoluteNames(name); // Test against the root name = getReadFolder().getFileSystem().getRoot().getName(); checkAbsoluteNames(name); // Test against some unknown file name = getManager().resolveName(name, "a/b/unknown"); checkAbsoluteNames(name); }
/** * Tests resolution of absolute names. */ public void testAbsoluteNames() throws Exception { // Test against the base folder FileName name = getReadFolder().getName(); checkAbsoluteNames(name); // Test against the root name = getReadFolder().getFileSystem().getRoot().getName(); checkAbsoluteNames(name); // Test against some unknown file name = getManager().resolveName(name, "a/b/unknown"); checkAbsoluteNames(name); }
/** * Tests resolution of absolute URI. */ public void testAbsoluteURI() throws Exception { final FileObject readFolder = getReadFolder(); // Try fetching base folder again by its URI final String uri = readFolder.getName().getURI(); FileObject file = getManager().resolveFile(uri, readFolder.getFileSystem().getFileSystemOptions()); assertSame("file object", readFolder, file); // Try fetching the filesystem root by its URI final String rootUri = readFolder.getName().getRootURI(); file = getManager().resolveFile(rootUri, readFolder.getFileSystem().getFileSystemOptions()); assertSame(readFolder.getFileSystem().getRoot(), file); assertEquals(rootUri, file.getName().getRootURI()); assertEquals(rootUri, file.getName().getURI()); assertEquals(FileName.ROOT_PATH, file.getName().getPath()); } }
/** * Tests resolution of absolute URI. */ public void testAbsoluteURI() throws Exception { final FileObject readFolder = getReadFolder(); // Try fetching base folder again by its URI final String uri = readFolder.getName().getURI(); FileObject file = getManager().resolveFile(uri, readFolder.getFileSystem().getFileSystemOptions()); assertSame("file object", readFolder, file); // Try fetching the filesystem root by its URI final String rootUri = readFolder.getName().getRootURI(); file = getManager().resolveFile(rootUri, readFolder.getFileSystem().getFileSystemOptions()); assertSame(readFolder.getFileSystem().getRoot(), file); assertEquals(rootUri, file.getName().getRootURI()); assertEquals(rootUri, file.getName().getURI()); assertEquals(FileName.ROOT_PATH, file.getName().getPath()); } }