@Override public boolean deleteResource( Properties conf ) throws IOException { return Files.deleteIfExists( getPath() ); }
@Override public String[] getChildIdentifiers( Properties conf, int depth, boolean fullyQualified ) throws IOException { if( !resourceExists( conf ) ) return new String[ 0 ]; Set<String> results = new LinkedHashSet<>(); PathMatcher pathMatcher = getPathMatcher(); int actualDepth = getPath().getNameCount() + depth; try( final Stream<Path> pathStream = Files.walk( getPath(), depth ) ) { pathStream .filter( path -> Files.isRegularFile( path ) || path.getNameCount() == actualDepth ) .filter( pathMatcher::matches ) .forEach( path -> results.add( fullyQualified ? path.toAbsolutePath().toString() : path.toString() ) ); } return results.toArray( new String[ results.size() ] ); }
@Override public boolean isDirectory( Properties conf ) throws IOException { return Files.isDirectory( getPath() ); }
protected void verify() { if( getPath() == null ) throw new IllegalArgumentException( "path may not be null" ); }
@Override public boolean resourceExists( Properties conf ) throws IOException { return Files.exists( getPath() ); }
@Override public String getFullIdentifier( Properties conf ) { return getPath().toAbsolutePath().toUri().toString(); }
@Override public long getModifiedTime( Properties conf ) throws IOException { return Files.getLastModifiedTime( getPath() ).to( TimeUnit.MILLISECONDS ); }
@Override public TapWith<Properties, InputStream, OutputStream> withSinkMode( SinkMode sinkMode ) { return create( getScheme(), getPath(), sinkMode ); }
@Override public TapWith<Properties, InputStream, OutputStream> withScheme( Scheme<Properties, InputStream, OutputStream, ?, ?> scheme ) { return create( scheme, getPath(), getSinkMode() ); }