@Override public void setAttribute( @Nullable Path pathArg, @Nullable final String attribute, @Nullable Object value, @Nullable LinkOption... options ) throws IOException { EightyPath path = checkProvider( pathArg ); EightyFileSystem eightyFileSystem = path._getFileSystem(); AttributeProvider attributeProvider = eightyFileSystem.getAttributeProvider(); attributeProvider.setAttribute( path, _n1( attribute ), _n2( value ), _nargs( options ) ); }
@Override public @Nullable FileSystem getFileSystem( @Nullable URI uri ) { return providerURIStuff.getFileSystem( _n0( uri ) ); }
public static <T, E extends Exception> T u( SupplierE<T, E> f ) { return _nn(f.get()); }
@Override public @Nullable <A extends BasicFileAttributes> A readAttributes( @Nullable Path pathArg, @Nullable final Class<A> type, @Nullable LinkOption... options ) throws IOException { EightyPath path = checkProvider( pathArg ); AttributeProvider attributeProvider = path._getFileSystem().getAttributeProvider(); return attributeProvider.readAttributes( path, _n1( type ), _nargs( options ) ); }
@Override public @Nullable WatchKey register( @Nullable WatchService watcher, @Nullable WatchEvent.Kind<?>... events ) throws IOException { if( !( watcher instanceof AttachedWatchService ) ) { throw new ProviderMismatchException(); } _nargs( events ); AttachedWatchService attachedWatcher = (AttachedWatchService) watcher; if( !fileSystem.get80().equals( attachedWatcher.getFileSystem() ) ) { throw new IllegalArgumentException(); } if( !attachedWatcher.isOpen() ) { throw new ClosedWatchServiceException(); } return attachedWatcher.register( this, _nn( events ) ); }
public @Nonnull static <T> T _n0( @Nullable T a ) { if( a == null ) { logger.warn( "parameter number 0 == null: " + getProblemMethod() ); throw new NullPointerException( "parameter number 0 == null" ); } return a; }
@Override public @Nullable DirectoryStream<Path> newDirectoryStream( @Nullable Path dirArg, @Nullable DirectoryStream.Filter<? super Path> filter ) throws IOException { EightyPath nnDir = checkProvider( dirArg ); EightyPath dir = toRealPath( nnDir ); if( !Files.exists( dir ) ) { throw new NoSuchFileException( "dir " + dir + " does not exist" ); } // todo set time now or after close ? FileTime now = FileTime.from( Clock.systemUTC().instant() ); if( !dir._getFileSystem().isReadOnly() ) { Files.getFileAttributeView( dirArg, BasicFileAttributeView.class ).setTimes( null, now, null ); } // todo: test for throw return dir._getFileSystem().addClosable( new EightyDirectoryStream( dirArg, dir._getFileSystem().get80().newDirectoryStream( dir ), _n1( filter ) ) ); }
@Override public @Nullable EightyPath toRealPath( @Nullable LinkOption... options ) throws IOException { EightyPath real = toRealPathEx( this, _nargs( options ) ); if( !Files.exists( real ) ) { throw new NoSuchFileException( "File " + this + " does not exist" ); } return real; }
public static <T> int findCommenSuffix( List<T> one, List<T> two ) { int i = 0; for ( ; i < one.size() && i < two.size(); i++ ) { if( !_nc(one.get( i )).equals( two.get( i ) )) { return i; } } return i; }
@Override public @Nullable Path getPath( @Nullable URI uri ) { return providerURIStuff.getPath( _n0( uri ) ); }
static <T, E extends Exception> T v( SupplierE<T, E> f ) { return _nn( f.get() ); }
@Override public @Nullable Map<String, Object> readAttributes( @Nullable Path pathArg, @Nullable String attributes, @Nullable LinkOption... options ) throws IOException { EightyPath path = checkProvider( pathArg ); AttributeProvider attributeProvider = path._getFileSystem().getAttributeProvider(); return attributeProvider.readAttributes( path, _n1( attributes ), _nargs( options ) ); }
@Override public void createDirectory( @Nullable Path dirArg, @Nullable FileAttribute<?>... attrs ) throws IOException { EightyFS eighty = checkProviderAndGet80( dirArg ); EightyPath dir = toRealPathEx( (EightyPath) _n0( dirArg ), NOFOLLOW_LINKS ); if( existsEx( dir, NOFOLLOW_LINKS ) ) { throw new FileAlreadyExistsException( dir.toString() ); } // an absolute path (toRealPath) that does not exist has a parent EightyPath parent = childGetParent( dir ); if( !Files.isDirectory( parent ) ) { throw new NoSuchFileException( parent.toString() ); } throwIfPathIsNotAccessible( dir ); eighty.createDirectory( dir, _nargs( attrs ) ); FileTime now = FileTime.from( Clock.systemUTC().instant() ); Files.getFileAttributeView( parent, BasicFileAttributeView.class ).setTimes( now, now, null ); parent._getFileSystem().signal( dir, StandardWatchEventKinds.ENTRY_CREATE ); }