@Override public URI toUri() throws IOException, SecurityException { if ( !isAbsolute() ) { return toAbsolutePath().toUri(); } if ( fs.provider().isDefault() && !isRealPath ) { try { return new URI( "default", host, toURIString(), null ); } catch ( URISyntaxException e ) { return null; } } try { return new URI( fs.provider().getScheme(), host, toURIString(), null ); } catch ( URISyntaxException e ) { return null; } }
/** * @throws IllegalArgumentException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#getFileAttributeView(java.nio.file.Path, java.lang.Class, java.nio.file.LinkOption...)">Original JavaDoc</a> */ public static <V extends FileAttributeView> V getFileAttributeView( final Path path, final Class<V> type, final LinkOption... options ) throws IllegalArgumentException { checkNotNull( "path", path ); checkNotNull( "type", type ); return providerOf( path ).getFileAttributeView( path, type, options ); }
/** * @throws IllegalArgumentException * @throws DirectoryNotEmptyException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#deleteIfExists(java.nio.file.Path)">Original JavaDoc</a> */ public static boolean deleteIfExists( final Path path, final DeleteOption... options ) throws IllegalArgumentException, DirectoryNotEmptyException, IOException, SecurityException { checkNotNull( "path", path ); return providerOf( path ).deleteIfExists( path, options ); }
private synchronized static Map<String, FileSystemProvider> buildProvidersMap() { final Map<String, FileSystemProvider> result = new HashMap<String, FileSystemProvider>(installedProviders.size() + 1); for (int i = 0; i < installedProviders.size(); i++) { final FileSystemProvider provider = installedProviders.get(i); if (i == 0) { provider.forceAsDefault(); result.put("default", provider); } result.put(provider.getScheme(), provider); } return unmodifiableMap(result); } }
protected boolean isFileScheme( final Path path ) { if ( path == null || path.getFileSystem() == null || path.getFileSystem().provider() == null ) { return false; } return path.getFileSystem().provider().getScheme().equals( "file" ); }
public boolean isRegularFile() throws IllegalAccessError, SecurityException { try { return getFileSystem().provider().readAttributes( this, BasicFileAttributes.class ).isRegularFile(); } catch ( IOException ioe ) { } return false; }
/** * @throws IllegalArgumentException * @throws UnsupportedOperationException * @throws NoSuchFileException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#newInputStream(java.nio.file.Path, java.nio.file.OpenOption...)">Original JavaDoc</a> */ public static InputStream newInputStream( final Path path, final OpenOption... options ) throws IllegalArgumentException, NoSuchFileException, UnsupportedOperationException, IOException, SecurityException { checkNotNull( "path", path ); return providerOf( path ).newInputStream( path, options ); }
public static Path createDirectories( final Path dir, final FileAttribute<?>... attrs ) throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { checkNotNull( "dir", dir ); final Path absoluteDir = dir.toAbsolutePath(); if ( !notExists( absoluteDir ) ) { throw new FileAlreadyExistsException( absoluteDir.toString() ); } Path parent = absoluteDir.getParent(); while ( parent != null ) { try { providerOf( parent ).checkAccess( parent ); break; } catch ( NoSuchFileException x ) { } parent = parent.getParent(); } if ( parent == null ) { throw new IOException( "Root directory does not exist" ); } // create directories Path child = parent; for ( final Path name : parent.relativize( dir ) ) { child = child.resolve( name ); providerOf( child ).createDirectory( child, attrs ); } return dir; }
/** * @throws IllegalArgumentException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#isReadable(java.nio.file.Path)">Original JavaDoc</a> */ public static boolean isReadable( final Path path ) throws IllegalArgumentException, SecurityException { checkNotNull( "path", path ); try { providerOf( path ).checkAccess( path, READ ); return true; } catch ( Exception x ) { } return false; }
/** * @throws IllegalArgumentException * @throws UnsupportedOperationException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#getFileAttributeView(java.nio.file.Path, java.lang.Class, java.nio.file.LinkOption...)">Original JavaDoc</a> */ public static <A extends BasicFileAttributes> A readAttributes( final Path path, final Class<A> type, final LinkOption... options ) throws IllegalArgumentException, NoSuchFileException, UnsupportedOperationException, IOException, SecurityException { checkNotNull( "path", path ); checkNotNull( "type", type ); return providerOf( path ).readAttributes( path, type, options ); }
@Override public File toFile() throws UnsupportedOperationException { if ( file == null ) { synchronized ( this ) { if ( isRegularFile() ) { try { file = File.createTempFile( "git", "temp" ); final InputStream in = getFileSystem().provider().newInputStream( this ); final OutputStream out = new FileOutputStream( file ); internalCopy( in, out ); in.close(); out.close(); } catch ( final Exception ex ) { file = null; } } else { throw new UnsupportedOperationException(); } } } return file; }
/** * @throws IllegalArgumentException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#isWritable(java.nio.file.Path)">Original JavaDoc</a> */ public static boolean isWritable( final Path path ) throws IllegalArgumentException, SecurityException { checkNotNull( "path", path ); try { providerOf( path ).checkAccess( path, WRITE ); return true; } catch ( Exception x ) { } return false; }
final BasicFileAttributes fileAttrs = path.getFileSystem().provider().getFileAttributeView( path, BasicFileAttributeView.class ).readAttributes();
/** * @throws UnsupportedOperationException * @throws IllegalArgumentException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#readAttributes(java.nio.file.Path, java.lang.String, java.nio.file.LinkOption...)">Original JavaDoc</a> */ public static Map<String, Object> readAttributes( final Path path, final String attributes, final LinkOption... options ) throws UnsupportedOperationException, NoSuchFileException, IllegalArgumentException, IOException, SecurityException { checkNotNull( "path", path ); checkNotEmpty( "attributes", attributes ); if ( notExists( path ) ) { throw new NoSuchFileException( path.toString() ); } return providerOf( path ).readAttributes( path, attributes, options ); }
public static void buildDotFile( final Path path, final OutputStream out, final FileAttribute<?>... attrs ) { if ( attrs != null && attrs.length > 0 ) { final Properties properties = new Properties(); for ( final FileAttribute<?> attr : attrs ) { if ( attr.value() instanceof Serializable ) { properties.put( attr.name(), attr.value() ); } } try { properties.store( out ); } catch ( final Exception e ) { throw new IOException( e ); } if ( path instanceof AttrHolder ) { ( (AttrHolder) path ).getAttrStorage().loadContent( properties ); } } else { path.getFileSystem().provider().deleteIfExists( dot( path ) ); } }
/** * @throws IllegalArgumentException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#isExecutable(java.nio.file.Path)">Original JavaDoc</a> */ public static boolean isExecutable( final Path path ) throws IllegalArgumentException, SecurityException { checkNotNull( "path", path ); try { providerOf( path ).checkAccess( path, EXECUTE ); return true; } catch ( Exception x ) { } return false; }
final BasicFileAttributes fileAttrs = path.getFileSystem().provider().getFileAttributeView( path, BasicFileAttributeView.class ).readAttributes();
public ConfigView( final AbstractPath path ) { super( path ); final BasicFileAttributes fileAttrs = path.getFileSystem().provider().getFileAttributeView( path, BasicFileAttributeView.class ).readAttributes();