protected void loadDotFile( final Path path ) { final Properties content = new Properties(); content.load( newInputStream( dot( path ) ) ); if ( path instanceof AttrHolder ) { ( (AttrHolder) path ).getAttrStorage().loadContent( content ); } }
@Override public Map<String, Object> readAttributes( final Path path, final String attributes ) throws UnsupportedOperationException, NoSuchFileException, IllegalArgumentException, IOException, SecurityException { checkNotNull( "path", path ); checkNotEmpty( "attributes", attributes ); final Properties original = new Properties( Files.readAttributes( path, attributes ) ); if ( attributes.equals( "*" ) && exists( dot( path ) ) ) { boolean isAttrHolder = path instanceof AttrHolder; if ( isAttrHolder && ( (AttrHolder) path ).getAttrStorage().getContent().size() > 0 ) { return ( (AttrHolder) path ).getAttrStorage().getAllContent(); } final Properties content = new Properties(); content.load( newInputStream( dot( path ) ) ); content.putAll( original ); if ( isAttrHolder ) { ( (AttrHolder) path ).getAttrStorage().loadContent( content ); } return content; } return original; }
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 ) ); } }