Java 类java.nio.file.attribute.FileAttributeView 实例源码

项目:mycore    文件:MCRFileSystemProvider.java   
@SuppressWarnings("unchecked")
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
    MCRPath mcrPath = MCRFileSystemUtils.checkPathAbsolute(path);
    if (type == null) {
        throw new NullPointerException();
    }
    //must support BasicFileAttributeView
    if (type == BasicFileAttributeView.class) {
        return (V) new BasicFileAttributeViewImpl(mcrPath);
    }
    if (type == MCRMD5AttributeView.class) {
        return (V) new MD5FileAttributeViewImpl(mcrPath);
    }
    return null;
}
项目:mycore    文件:MCRDirectoryStream.java   
@SuppressWarnings("unchecked")
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
    if (path != null) {
        MCRPath file = checkRelativePath(path);
        if (file.getNameCount() != 1) {
            throw new InvalidPathException(path.toString(), "'path' must have one name component.");
        }
    }
    checkClosed();
    if (type == null) {
        throw new NullPointerException();
    }
    //must support BasicFileAttributeView
    if (type == BasicFileAttributeView.class) {
        return (V) new BasicFileAttributeViewImpl(this, path);
    }
    if (type == MCRMD5AttributeView.class) {
        return (V) new MD5FileAttributeViewImpl(this, path);
    }
    return null;
}
项目:incubator-taverna-language    文件:BundleFileSystemProvider.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path,
        Class<V> type, LinkOption... options) {
    BundleFileSystem fs = (BundleFileSystem) path.getFileSystem();
    if (path.toAbsolutePath().equals(fs.getRootDirectory())) {
        // Bug in ZipFS, it will fall over as there is no entry for /
        //
        // Instead we'll just give a view of the source (e.g. the zipfile
        // itself).
        // Modifying its times is a bit futile since they are likely to be
        // overriden when closing, but this avoids a NullPointerException
        // in Files.setTimes().
        return Files.getFileAttributeView(fs.getSource(), type, options);
    }
    return origProvider(path).getFileAttributeView(fs.unwrap(path), type,
            options);
}
项目:tinyMediaManager    文件:FSTest.java   
private Set<String> getSupportedFileAttributes(FileStore fs) {
  Set<String> attrs = new HashSet<String>();
  if (fs.supportsFileAttributeView(AclFileAttributeView.class)) {
    attrs.add("acl");
  }
  if (fs.supportsFileAttributeView(BasicFileAttributeView.class)) {
    attrs.add("basic");
  }
  if (fs.supportsFileAttributeView(FileOwnerAttributeView.class)) {
    attrs.add("owner");
  }
  if (fs.supportsFileAttributeView(UserDefinedFileAttributeView.class)) {
    attrs.add("user");
  }
  if (fs.supportsFileAttributeView(DosFileAttributeView.class)) {
    attrs.add("dos");
  }
  if (fs.supportsFileAttributeView(PosixFileAttributeView.class)) {
    attrs.add("posix");
  }
  if (fs.supportsFileAttributeView(FileAttributeView.class)) {
    attrs.add("file");
  }
  return attrs;
}
项目:ephemeralfs    文件:AttributeLookup.java   
public boolean supportsFileAttributeView(
        Class<? extends FileAttributeView> type) {

    String name = "notFound";
    if(type == BasicFileAttributeView.class) {
        name = "basic";
    } else if(type == DosFileAttributeView.class) {
        name = "dos";
    } else if(type == PosixFileAttributeView.class) {
        name = "posix";
    } else if(type == FileOwnerAttributeView.class) {
        name = "owner";
    }

    return  attributeSets.containsKey(name);
}
项目:ephemeralfs    文件:EphemeralFsSecureDirectoryStream.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path,
        Class<V> type, LinkOption... options) {
    final EphemeralFsPath efsPath = cast(path);
    synchronized(efsPath.fs.fsLock) {
        return efsPath.fs.getFileAttributeView(
                new EphemeralFsPathProvider() {
                    @Override
                    public EphemeralFsPath get() {
                        return translate(efsPath);
                    }
                }, 
                type, 
                closeChecker, 
                options);
    }
}
项目:eightyfs    文件:AttributeProvider.java   
public <V extends FileAttributeView> Optional<V> getFileAttributeView( EightyPath path, final Class<V> type, LinkOption... options ) {
    if( !isViewSupported( type ) ) {
        return Optional.empty();
    }

    if( !existsEx( path, options ) ) {
        return Optional.of( getFileAttributeViewDummy( path, type ) );
    }

    EightyPath real = toRealPathEx( path, options );

    EightyFileSystem eightyFileSystem = path._getFileSystem();
    EightyFS efs = eightyFileSystem.get80();

    V fav = getSymLinkSensitiveFileAttributeView( type, real, efs );

    handleReadOnlyFileSystems( eightyFileSystem, fav );

    return Optional.of( fav );
}
项目:jimfs    文件:JimfsSecureDirectoryStream.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(
    Path path, Class<V> type, LinkOption... options) {
  checkOpen();
  final JimfsPath checkedPath = checkPath(path);
  final ImmutableSet<LinkOption> optionsSet = Options.getLinkOptions(options);
  return view.getFileAttributeView(
      new FileLookup() {
        @Override
        public File lookup() throws IOException {
          checkOpen(); // per the spec, must check that the stream is open for each view operation
          return view
              .lookUpWithLock(checkedPath, optionsSet)
              .requireExists(checkedPath)
              .file();
        }
      },
      type);
}
项目:jimfs    文件:AclAttributeProviderTest.java   
@Test
public void testView() throws IOException {
  AclFileAttributeView view =
      provider.view(
          fileLookup(),
          ImmutableMap.<String, FileAttributeView>of(
              "owner", new OwnerAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS)));
  assertNotNull(view);

  assertThat(view.name()).isEqualTo("acl");

  assertThat(view.getAcl()).isEqualTo(defaultAcl);

  view.setAcl(ImmutableList.<AclEntry>of());
  view.setOwner(FOO);

  assertThat(view.getAcl()).isEqualTo(ImmutableList.<AclEntry>of());
  assertThat(view.getOwner()).isEqualTo(FOO);

  assertThat(file.getAttribute("acl", "acl")).isEqualTo(ImmutableList.<AclEntry>of());
}
项目:truevfs    文件:TFileSystemProvider.java   
@Override
@Nullable
public <V extends FileAttributeView> V getFileAttributeView(
        Path path,
        Class<V> type,
        LinkOption... options) {
    return promote(path).getFileAttributeView(type, options);
}
项目:jdk8u-jdk    文件:FaultyFileSystem.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
项目:openjdk-jdk10    文件:TestProvider.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    Path delegate = theFileSystem.unwrap(file);
    return defaultProvider.getFileAttributeView(delegate, type, options);
}
项目:openjdk-jdk10    文件:FaultyFileSystem.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
项目:openjdk9    文件:TestProvider.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    Path delegate = theFileSystem.unwrap(file);
    return defaultProvider.getFileAttributeView(delegate, type, options);
}
项目:openjdk9    文件:FaultyFileSystem.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
项目:java-cloud-filesystem-provider    文件:DefaultCloudFileSystemImplementation.java   
/**
 * Can return a {@link CloudFileAttributesView}
 * @param type {@link CloudFileAttributesView} or {@link BasicFileAttributeView}
 */
@Override
public <V extends FileAttributeView> V getFileAttributeView(BlobStoreContext blobStoreContext, Class<V> type, CloudPath cloudPath) {
    if (CloudFileAttributesView.class.equals(type) || BasicFileAttributeView.class.equals(type)) {
        return type.cast(new CloudFileAttributesView(blobStoreContext, cloudPath));
    }

    return null;
}
项目:filesystem    文件:AbstractLocalFileSystemProvider.java   
@Override
@SuppressWarnings( "unchecked" )
public <V extends FileAttributeView> V getFileAttributeView( Path path, Class<V> type, LinkOption... options )
{
    if( type.isAssignableFrom( BasicFileAttributeView.class ) )
    {
        P p = toCachePath( path );
        return (V) p.getFileSystem().getFileSystemIO().getAttributeView( p.getResolvedPath() );
    }
    throw new UnsupportedOperationException();
}
项目:baratine    文件:FileProviderBase.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path,
                                                            Class<V> type,
                                                            LinkOption... options)
{
  throw new UnsupportedOperationException();
}
项目:baratine    文件:JFileSystemProvider.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path,
                                                            Class<V> type,
                                                            LinkOption... options)
{
  // TODO Auto-generated method stub
  throw new UnsupportedOperationException();
}
项目:jdk8u_jdk    文件:FaultyFileSystem.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
项目:lookaside_java-1.8.0-openjdk    文件:FaultyFileSystem.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
项目:ParallelGit    文件:GfsFileStore.java   
@Override
public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
  return
    type.isAssignableFrom(GfsFileAttributeView.Basic.class)
      || type.isAssignableFrom(GfsFileAttributeView.Posix.class)
      || type.isAssignableFrom(GfsFileAttributeView.Git.class);
}
项目:ParallelGit    文件:FilesGetAttributeViewTest.java   
@Test
public void getFileAttributeViewFromFile_shouldBeNotNull() throws IOException {
  initRepository();
  writeToCache("/file.txt");
  commitToMaster();
  initGitFileSystem();
  assertNotNull(Files.getFileAttributeView(gfs.getPath("/file.txt"), FileAttributeView.class));
}
项目:test-fs    文件:TestFileSystemProvider.java   
/** {@inheritDoc} */
@Override
public < V extends FileAttributeView > V getFileAttributeView(Path path, Class< V > type, LinkOption... options) {

    path = ((TestPath) path).unwrap();

    try {
        checkIfRemoved(path);
    } catch (NoSuchFileException e) {
        return null;
    }

    return provider.getFileAttributeView(path, type, options);
}
项目:infobip-open-jdk-8    文件:FaultyFileSystem.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
项目:jdk8u-dev-jdk    文件:FaultyFileSystem.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
                                                            Class<V> type,
                                                            LinkOption... options)
{
    return Files.getFileAttributeView(unwrap(file), type, options);
}
项目:ephemeralfs    文件:EphemeralFsSecureDirectoryStream.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Class<V> type) {
    synchronized(myPath.fs.fsLock) {
        return myPath.fs.getFileAttributeView(
                new EphemeralFsPathProvider() {

                    @Override
                    public EphemeralFsPath get() {
                        return myDirectory.getPathToRoot();
                    }
                },
                type, 
                closeChecker);
    }
}
项目:ephemeralfs    文件:EphemeralFsFileSystem.java   
public <V extends FileAttributeView> V getFileAttributeView(
        EphemeralFsPathProvider pathProvider,
        Class<V> type,
        CloseChecker closeChecker,
        LinkOption... options) {
    return getFileAttributesViewBuilder(
            pathProvider, closeChecker, options).build(type);
}
项目:ephemeralfs    文件:FileAttributesViewBuilder.java   
public <V extends FileAttributeView> V build(Class<V> type) {
    if (type == BasicFileAttributeView.class) {
        return (V) new EphemeralFsBasicFileAttributesView();
    } else if (type == PosixFileAttributeView.class) {
        return (V) new EphemeralFsPosixFileAttributesView();
    } else if (type == DosFileAttributeView.class) {
        return (V) new EphemeralFsDosFileAttributesView();
    } else if (type == FileOwnerAttributeView.class) {
        return (V) new EphemeralFsFileOwnerAttributeView();
    } else {
        throw new UnsupportedOperationException("type:" + type
                + " is not supported");
    }
}
项目:ephemeralfs    文件:EphemeralFsFileSystemProvider.java   
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path,
        Class<V> type, LinkOption... options) {
    EphemeralFsPath efsPath = toEfsPath(path);
    return efsPath.fs.getFileAttributeView(
            new EphemeralFsPathProvider.ConstefsPathProvider(efsPath), 
            type, 
            CloseChecker.ALWAYS_OPEN, 
            options);
}
项目:archive-fs    文件:TarFileAttributeView.java   
@SuppressWarnings("unchecked")
static <V extends FileAttributeView> V get(TarPath path, Class<V> type) {
    if (type == null) {
        throw new NullPointerException();
    }
    if (type == BasicFileAttributeView.class) {
        return (V) new TarFileAttributeView(path, false);
    }
    if (type == TarFileAttributeView.class) {
        return (V) new TarFileAttributeView(path, true);
    }
    return null;
}
项目:eightyfs    文件:EightyProvider.java   
@Override
public
@Nullable
<V extends FileAttributeView> V getFileAttributeView( @Nullable Path pathArg, @Nullable final Class<V> type, @Nullable LinkOption... options ) {
    EightyPath path = checkProvider( pathArg );
    AttributeProvider attributeProvider = path._getFileSystem().getAttributeProvider();

    return attributeProvider.getFileAttributeView( path, _n1( type ), _nargs( options ) ).orElse( null );
}
项目:eightyfs    文件:OneClassAttributes.java   
@Override
public Object read( FileAttributeView view, String attiName ) {
    checkViewType( view );

    return reads.getOrThrow( attiName,
                             new IllegalArgumentException( "attribute " + attiName + " not in view " + getViewName() ) ).
            apply( viewType.cast( view ));
}
项目:eightyfs    文件:OneClassAttributes.java   
@Override
public void set( FileAttributeView view, String name, Object value ) {
    checkViewType( view );

    writes.getOrThrow( name,
                       new IllegalArgumentException( "no such attribute " + name ) ).
            accept( viewType.cast( view ), value );
}
项目:eightyfs    文件:AttributeProvider.java   
private <V extends FileAttributeView> void handleReadOnlyFileSystems( EightyFileSystem eightyFileSystem, V fav ) {
    if( eightyFileSystem.isReadOnly() ) {
        if( !( fav instanceof ReadonlySettable ) ) {
            throw new UnsupportedOperationException( "the attribute view need to implement ReadonlySettable in order to make Readonly Filesystems work" );
        }

        ( (ReadonlySettable) ( fav ) ).setReadonly();
    }
}
项目:eightyfs    文件:AttributeProvider.java   
private <V extends FileAttributeView> V getSymLinkSensitiveFileAttributeView( Class<V> type, EightyPath real, EightyFS efs ) {

        Optional<EightySymLink> sym = real._getFileSystem().getSymLink( real );

        if( sym.isPresent() ) {
            return addIsLinkIfPossible( type, efs.getFileAttributeView( sym.get().getHost(), type ) );
        }

        // not a link
        return efs.getFileAttributeView( real, type );
    }
项目:eightyfs    文件:AttributeProvider.java   
/**
 * if the the FAV is actually a BasicFileAttributeView then there is an isLink method
 * if this is not already set and FAV implements LinkInfoSettable use it to add this link info
 */
@SuppressWarnings( "PMD.CollapsibleIfStatements" )
private <V extends FileAttributeView> V addIsLinkIfPossible( Class<V> type, V fav ) {
    if( BasicFileAttributeView.class.isAssignableFrom( type ) ) {
        if( (! v( () -> BasicFileAttributeView.class.cast( fav ).readAttributes()).isSymbolicLink() )) {
            if( !( fav instanceof LinkInfoSettable ) ) {
                throw new UnsupportedOperationException( "the attribute view need to implement LinkInfoSettable in order to make SymLinks work" );
            }

            ( (LinkInfoSettable) ( fav ) ).setLink();
        }
    }

    return fav;
}
项目:eightyfs    文件:AttributeProvider.java   
private <V extends FileAttributeView> V getFileAttributeViewDummy( Path path, final Class<V> type ) {
    return RuntimeProxy.of( type, name -> {
        if( name.equals( "name" ) ) {
            return "FileAttributeProxy";
        }

        throw new NoSuchFileException( path.toString() );
    } );

}
项目:eightyfs    文件:AttributeProvider.java   
public <A extends BasicFileAttributes> A readAttributes( EightyPath path, final Class<A> type, LinkOption... options ) throws IOException {
    if( !isReadSupported( type ) ) {
        throw new UnsupportedOperationException( type + " not a supported FileAttributes class" );
    }

    if( !existsEx( path, options ) ) {
        throw new NoSuchFileException( path + " does not exist" );
    }

    RWAttributes att = fromRead.get( type ).orElseThrow( () -> new UnsupportedOperationException( type + " not a supported FileAttributes class" ) );
    FileAttributeView fav = getFileAttributeView( path, att.getViewType(), options ).orElseThrow( () -> new UnsupportedOperationException( type + " not a supported FileAttributes class" ) );

    return att.getReadAttributes( type, fav );
}
项目:eightyfs    文件:TwoClassAttributes.java   
public Object read( FileAttributeView view, String attiName ) {
    checkViewType( view );

    return reads.getOrThrow( attiName,
                             new IllegalArgumentException( "attribute " + attiName + " not in view " + getViewName() ) )
            .apply( v( () -> readType.cast( viewType.cast( view ).readAttributes() ) ) );
}