public void clearCache() { file = null; attrsStorage.clear(); }
@Override public synchronized boolean deleteIfExists( final Path path, final DeleteOption... options ) throws IllegalArgumentException, DirectoryNotEmptyException, IOException, SecurityException { final boolean result = Files.deleteIfExists( path, options ); try { Files.deleteIfExists( dot( path ), options ); } catch ( Exception ex ) { } if ( path instanceof AttrHolder ) { ( (AttrHolder) path ).getAttrStorage().clear(); } return result; }
@Override public synchronized void delete( final Path path, final DeleteOption... options ) throws IllegalArgumentException, NoSuchFileException, DirectoryNotEmptyException, IOException, SecurityException { Files.delete( path, options ); try { Files.deleteIfExists( dot( path ), options ); } catch ( Exception ex ) { } if ( path instanceof AttrHolder ) { ( (AttrHolder) path ).getAttrStorage().clear(); } }
( (AttrHolder) path ).getAttrStorage().clear();
( (AttrHolder) path ).getAttrStorage().clear();
@Test public void testGetAttribute() { final Path file = getFilePath(); ioService().deleteIfExists( file ); ioService().write( file, "ooooo!", Collections.<OpenOption>emptySet(), new FileAttribute<Object>() { @Override public String name() { return "dcore.author"; } @Override public Object value() { return "AuthorName"; } } ); assertNotNull( ioService().getAttribute( file, "dcore:dcore.author" ) ); assertNull( ioService().getAttribute( file, "dcore:dcore.not_here" ) ); assertNotNull( ioService().getAttribute( file, "dcore.author" ) ); assertNull( ioService().getAttribute( file, "something" ) ); ( (AttrHolder) file ).getAttrStorage().clear(); assertNotNull( ioService().getAttribute( file, "dcore:dcore.author" ) ); assertNull( ioService().getAttribute( file, "dcore:dcore.not_here" ) ); assertNotNull( ioService().getAttribute( file, "dcore.author" ) ); assertNull( ioService().getAttribute( file, "something" ) ); }
@Test public void testGetAttributeView() { final Path file = getFilePath(); ioService().deleteIfExists( file ); ioService().write( file, "ooooo!", Collections.<OpenOption>emptySet(), new FileAttribute<Object>() { @Override public String name() { return "dcore.author"; } @Override public Object value() { return "AuthorName"; } } ); assertNotNull( ioService().getFileAttributeView( file, BasicFileAttributeView.class ) ); assertNull( ioService().getFileAttributeView( file, MyAttrsView.class ) ); assertNotNull( ioService().getFileAttributeView( file, XDublinCoreView.class ) ); final DublinCoreAttributes attr = ioService().getFileAttributeView( file, XDublinCoreView.class ).readAttributes(); assertEquals( "AuthorName", attr.getAuthor() ); ( (AttrHolder) file ).getAttrStorage().clear(); assertNotNull( ioService().getFileAttributeView( file, BasicFileAttributeView.class ) ); assertNull( ioService().getFileAttributeView( file, MyAttrsView.class ) ); assertNotNull( ioService().getFileAttributeView( file, XDublinCoreView.class ) ); }