@Override public boolean isOpen() { return delegate.isOpen(); }
private static void checkGcs() { FileSystem fs = FileSystems.getFileSystem(URI.create("gs://domain-registry-alpha")); System.out.println("Success! We can instantiate a gs:// filesystem."); System.out.println("isOpen: " + fs.isOpen()); System.out.println("isReadOnly: " + fs.isReadOnly()); } }
return pathObject == null || Files.isDirectory(pathObject); } finally { if (fileSystem != null && fileSystem.isOpen()) { try { fileSystem.close();
@Test public void testGetters() throws IOException { try (FileSystem fs = CloudStorageFileSystem.forBucket("bucket")) { assertThat(fs.isOpen()).isTrue(); assertThat(fs.isReadOnly()).isFalse(); assertThat(fs.getRootDirectories()).containsExactly(fs.getPath("/")); assertThat(fs.getFileStores()).isEmpty(); assertThat(fs.getSeparator()).isEqualTo("/"); assertThat(fs.supportedFileAttributeViews()).containsExactly("basic", "gcs"); } }
@Override public boolean isOpen() { return rootFs.isOpen(); }
@Override public boolean isOpen() { if (origFS == null) { return false; } return origFS.isOpen(); }
@Override public boolean isOpen() { return delegate.isOpen(); }
@Override public boolean isOpen() { return rootFs.isOpen(); }
@Override public boolean isOpen() { return rootFs.isOpen(); }
/** * Thread-safe ClosedFileSystemException test * * @return */ protected FileSystem getOrigFS() { FileSystem orig = origFS; if (orig == null || !orig.isOpen()) { throw new ClosedFileSystemException(); } return orig; }
@Override public boolean isOpen() {return wrapped().isOpen();}
public FileSystem getFileSystem( URI uri ) { checkURI( uri ); String id = uriMapper.getSchemeSpecificPart( uri ); FileSystem ret = fileSystems.get( id ); if( ret == null ) { throw new FileSystemNotFoundException( uri.toString() ); } if( !ret.isOpen() ) { fileSystems.remove( id ); // for GC throw new FileSystemNotFoundException( uri.toString() ); } return ret; }
private EightyPath checkProvider( @Nullable Path path ) { if( path == null ) { throw new IllegalArgumentException( "argument was null" ); } if( path.getFileSystem().provider() != this ) { throw new ProviderMismatchException( "expected path for " + getScheme() + " got " + path.getFileSystem().provider().getScheme() ); } if( !path.getFileSystem().isOpen() ) { throw new ClosedFileSystemException(); } return (EightyPath) path; }
private EightyFS checkProviderAndGet80( @Nullable Path path ) { if( path == null ) { throw new IllegalArgumentException( "argument was null" ); } if( path.getFileSystem().provider() != this ) { throw new ProviderMismatchException( "expected path for " + getScheme() + " got " + path.getFileSystem().provider().getScheme() ); } if( !path.getFileSystem().isOpen() ) { throw new ClosedFileSystemException(); } return ( (EightyFileSystem) path.getFileSystem() ).get80(); }
@Test @Category( Closable.class ) public void testClosedFSisClosed() throws Exception { assertThat( getClosedFS().isOpen(), is( false ) ); }
@After public void closeFileSystem() throws IOException { if (this.fs.isOpen()) { this.fs.close(); } }
@Test public void isOpen() { Assert.assertTrue("Should report as open", fileSystem.isOpen()); }
@Test public void isOpenAfterClose() throws IOException { fileSystem.close(); Assert.assertFalse("Should report as closed", fileSystem.isOpen()); }
@Test public void closeNotDelete() throws Exception { Path path = Files.createTempFile("bundle", ".zip"); Bundle bundle = Bundles.createBundle(path); assertFalse(bundle.isDeleteOnClose()); assertTrue(Files.exists(bundle.getSource())); assertTrue(bundle.getFileSystem().isOpen()); bundle.close(); assertTrue(Files.exists(bundle.getSource())); assertFalse(bundle.getFileSystem().isOpen()); }
@Test public void closeDeleteTemp() throws Exception { Bundle bundle = Bundles.createBundle(); assertTrue(Files.exists(bundle.getSource())); assertTrue(bundle.getFileSystem().isOpen()); assertTrue(bundle.isDeleteOnClose()); bundle.close(); assertFalse(Files.exists(bundle.getSource())); assertFalse(bundle.getFileSystem().isOpen()); }