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

项目: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);
}
项目:Personifiler    文件:FileSystemWriter.java   
private String getOwnerName(File file)
{
    String directory = file.getAbsolutePath();
    Path path = Paths.get(directory);
    FileOwnerAttributeView ownerAttributeView = Files.getFileAttributeView(path, FileOwnerAttributeView.class);
    UserPrincipal owner = null;

    try
    {
        owner = ownerAttributeView.getOwner();
    } catch (IOException e)
    {
        throw new PersonifilerException(e);
    }

    return owner.getName();
}
项目: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    文件:OwnerFileAttributesTest.java   
@Test
public void testReadOwner() throws Exception {
    for(Path path : Arrays.asList(
            Files.createDirectory(root.resolve("dir")),
            Files.createFile(root.resolve("file")))) {

        FileOwnerAttributeView view = Files.getFileAttributeView(path, FileOwnerAttributeView.class);
        assertNotNull(view.getOwner());
        view.setOwner(view.getOwner());

        UserPrincipal owner = (UserPrincipal) Files.getAttribute(path, "owner:owner");
        assertNotNull(owner);
    }

}
项目:eightyfs    文件:RWAttributesBuilder.java   
public RWAttributesBuilder addOwner() {
    attributes( "owner", FileOwnerAttributeView.class ).
            attribute( "owner",
                       FunctionE.u( FileOwnerAttributeView::getOwner ),
                       BiConsumerE.u( ( v, p ) -> v.setOwner( (UserPrincipal) p ) ) );

    return this;
}
项目:eightyfs    文件:ReadonlyFS.java   
public static EightyFS roCreate( Object hostRoot, RWAttributesBuilder ab, Map<String, Object> env ) {
    ab.attributes( "owner", FileOwnerAttributeView.class ).
            attribute( "owner", FunctionE.u( FileOwnerAttributeView::getOwner ));

    ab.addPosix();

    return new ReadonlyFS((Path) hostRoot);
}
项目:jsr203-hadoop    文件:HadoopFileSystem.java   
@SuppressWarnings("unchecked")
<V extends FileAttributeView> V getView(HadoopPath path, Class<V> type) {
       if (type == null)
           throw new NullPointerException();
       if (type == BasicFileAttributeView.class)
           return (V)new HadoopBasicFileAttributeView(path, false);
       if (type == HadoopBasicFileAttributeView.class)
           return (V)new HadoopBasicFileAttributeView(path, true);
       if (type == FileOwnerAttributeView.class)
           return (V)new HadoopPosixFileAttributeView(path, false);
       if (type == PosixFileAttributeView.class)
           return (V)new HadoopPosixFileAttributeView(path, true);
       return null;
   }
项目:jsr203-hadoop    文件:TestFiles.java   
@Test
public void getFileAttributeViewFileOwnerAttributeView() throws IOException {
  Path rootPath = Paths.get(clusterUri);
  Path path = Files.createTempFile(rootPath, "test", "tmp");
  FileOwnerAttributeView view = Files.getFileAttributeView(path,
      FileOwnerAttributeView.class);
  Assert.assertNotNull(view);
  Assert.assertEquals("owner", view.name());
}
项目:wildfly-core    文件:FilePersistenceUtils.java   
private static boolean supportsFileOwnerAttributeView(Path path, Class<? extends FileOwnerAttributeView> view) {
    FileStore store;
    try {
        store = Files.getFileStore(path);
    } catch (IOException e) {
        return false;
    }
    return store.supportsFileAttributeView(view);
}
项目:jimfs    文件:PosixAttributeProvider.java   
@Override
public PosixFileAttributeView view(
    FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
  return new View(
      lookup,
      (BasicFileAttributeView) inheritedViews.get("basic"),
      (FileOwnerAttributeView) inheritedViews.get("owner"));
}
项目:jimfs    文件:OwnerAttributeProviderTest.java   
@Test
public void testView() throws IOException {
  FileOwnerAttributeView view = provider.view(fileLookup(), NO_INHERITED_VIEWS);
  assertThat(view).isNotNull();

  assertThat(view.name()).isEqualTo("owner");
  assertThat(view.getOwner()).isEqualTo(createUserPrincipal("user"));

  view.setOwner(createUserPrincipal("root"));
  assertThat(view.getOwner()).isEqualTo(createUserPrincipal("root"));
  assertThat(file.getAttribute("owner", "owner")).isEqualTo(createUserPrincipal("root"));
}
项目:eightyfs    文件:GuestFileAttributeView.java   
public FileOwnerAttributeView ownerHost() {
    return (FileOwnerAttributeView)host;
}
项目:jimfs    文件:OwnerAttributeProvider.java   
@Override
public Class<FileOwnerAttributeView> viewType() {
  return FileOwnerAttributeView.class;
}
项目:jimfs    文件:OwnerAttributeProvider.java   
@Override
public FileOwnerAttributeView view(
    FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
  return new View(lookup);
}
项目:jimfs    文件:PosixAttributeProvider.java   
protected View(
    FileLookup lookup, BasicFileAttributeView basicView, FileOwnerAttributeView ownerView) {
  super(lookup);
  this.basicView = checkNotNull(basicView);
  this.ownerView = checkNotNull(ownerView);
}
项目:jimfs    文件:AclAttributeProvider.java   
@Override
public AclFileAttributeView view(
    FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
  return new View(lookup, (FileOwnerAttributeView) inheritedViews.get("owner"));
}
项目:jimfs    文件:AclAttributeProvider.java   
public View(FileLookup lookup, FileOwnerAttributeView ownerView) {
  super(lookup);
  this.ownerView = checkNotNull(ownerView);
}
项目:OpenJSharp    文件:Files.java   
/**
 * Returns the owner of a file.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * @param   path
 *          The path to the file
 * @param   options
 *          options indicating how symbolic links are handled
 *
 * @return  A user principal representing the owner of the file
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkRead(String) checkRead} method
 *          denies read access to the file.
 */
public static UserPrincipal getOwner(Path path, LinkOption... options) throws IOException {
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class, options);
    if (view == null)
        throw new UnsupportedOperationException();
    return view.getOwner();
}
项目:OpenJSharp    文件:Files.java   
/**
 * Updates the file owner.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * <p> <b>Usage Example:</b>
 * Suppose we want to make "joe" the owner of a file:
 * <pre>
 *     Path path = ...
 *     UserPrincipalLookupService lookupService =
 *         provider(path).getUserPrincipalLookupService();
 *     UserPrincipal joe = lookupService.lookupPrincipalByName("joe");
 *     Files.setOwner(path, joe);
 * </pre>
 *
 * @param   path
 *          The path to the file
 * @param   owner
 *          The new file owner
 *
 * @return  The path
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkWrite(String) checkWrite}
 *          method denies write access to the file.
 *
 * @see FileSystem#getUserPrincipalLookupService
 * @see java.nio.file.attribute.UserPrincipalLookupService
 */
public static Path setOwner(Path path, UserPrincipal owner)
    throws IOException
{
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class);
    if (view == null)
        throw new UnsupportedOperationException();
    view.setOwner(owner);
    return path;
}
项目:jdk8u-jdk    文件:Files.java   
/**
 * Returns the owner of a file.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * @param   path
 *          The path to the file
 * @param   options
 *          options indicating how symbolic links are handled
 *
 * @return  A user principal representing the owner of the file
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkRead(String) checkRead} method
 *          denies read access to the file.
 */
public static UserPrincipal getOwner(Path path, LinkOption... options) throws IOException {
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class, options);
    if (view == null)
        throw new UnsupportedOperationException();
    return view.getOwner();
}
项目:jdk8u-jdk    文件:Files.java   
/**
 * Updates the file owner.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * <p> <b>Usage Example:</b>
 * Suppose we want to make "joe" the owner of a file:
 * <pre>
 *     Path path = ...
 *     UserPrincipalLookupService lookupService =
 *         provider(path).getUserPrincipalLookupService();
 *     UserPrincipal joe = lookupService.lookupPrincipalByName("joe");
 *     Files.setOwner(path, joe);
 * </pre>
 *
 * @param   path
 *          The path to the file
 * @param   owner
 *          The new file owner
 *
 * @return  The path
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkWrite(String) checkWrite}
 *          method denies write access to the file.
 *
 * @see FileSystem#getUserPrincipalLookupService
 * @see java.nio.file.attribute.UserPrincipalLookupService
 */
public static Path setOwner(Path path, UserPrincipal owner)
    throws IOException
{
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class);
    if (view == null)
        throw new UnsupportedOperationException();
    view.setOwner(owner);
    return path;
}
项目:openjdk-jdk10    文件:Files.java   
/**
 * Returns the owner of a file.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * @param   path
 *          The path to the file
 * @param   options
 *          options indicating how symbolic links are handled
 *
 * @return  A user principal representing the owner of the file
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies
 *          {@link RuntimePermission}{@code ("accessUserInformation")}
 *          or its {@link SecurityManager#checkRead(String) checkRead} method
 *          denies read access to the file.
 */
public static UserPrincipal getOwner(Path path, LinkOption... options) throws IOException {
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class, options);
    if (view == null)
        throw new UnsupportedOperationException();
    return view.getOwner();
}
项目:openjdk-jdk10    文件:Files.java   
/**
 * Updates the file owner.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * <p> <b>Usage Example:</b>
 * Suppose we want to make "joe" the owner of a file:
 * <pre>
 *     Path path = ...
 *     UserPrincipalLookupService lookupService =
 *         provider(path).getUserPrincipalLookupService();
 *     UserPrincipal joe = lookupService.lookupPrincipalByName("joe");
 *     Files.setOwner(path, joe);
 * </pre>
 *
 * @param   path
 *          The path to the file
 * @param   owner
 *          The new file owner
 *
 * @return  The given path
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies
 *          {@link RuntimePermission}{@code ("accessUserInformation")}
 *          or its {@link SecurityManager#checkWrite(String) checkWrite}
 *          method denies write access to the file.
 *
 * @see FileSystem#getUserPrincipalLookupService
 * @see java.nio.file.attribute.UserPrincipalLookupService
 */
public static Path setOwner(Path path, UserPrincipal owner)
    throws IOException
{
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class);
    if (view == null)
        throw new UnsupportedOperationException();
    view.setOwner(owner);
    return path;
}
项目:openjdk9    文件:Files.java   
/**
 * Returns the owner of a file.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * @param   path
 *          The path to the file
 * @param   options
 *          options indicating how symbolic links are handled
 *
 * @return  A user principal representing the owner of the file
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies
 *          {@link RuntimePermission}{@code ("accessUserInformation")}
 *          or its {@link SecurityManager#checkRead(String) checkRead} method
 *          denies read access to the file.
 */
public static UserPrincipal getOwner(Path path, LinkOption... options) throws IOException {
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class, options);
    if (view == null)
        throw new UnsupportedOperationException();
    return view.getOwner();
}
项目:openjdk9    文件:Files.java   
/**
 * Updates the file owner.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * <p> <b>Usage Example:</b>
 * Suppose we want to make "joe" the owner of a file:
 * <pre>
 *     Path path = ...
 *     UserPrincipalLookupService lookupService =
 *         provider(path).getUserPrincipalLookupService();
 *     UserPrincipal joe = lookupService.lookupPrincipalByName("joe");
 *     Files.setOwner(path, joe);
 * </pre>
 *
 * @param   path
 *          The path to the file
 * @param   owner
 *          The new file owner
 *
 * @return  The given path
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies
 *          {@link RuntimePermission}{@code ("accessUserInformation")}
 *          or its {@link SecurityManager#checkWrite(String) checkWrite}
 *          method denies write access to the file.
 *
 * @see FileSystem#getUserPrincipalLookupService
 * @see java.nio.file.attribute.UserPrincipalLookupService
 */
public static Path setOwner(Path path, UserPrincipal owner)
    throws IOException
{
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class);
    if (view == null)
        throw new UnsupportedOperationException();
    view.setOwner(owner);
    return path;
}
项目:Java8CN    文件:Files.java   
/**
 * Returns the owner of a file.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * @param   path
 *          The path to the file
 * @param   options
 *          options indicating how symbolic links are handled
 *
 * @return  A user principal representing the owner of the file
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkRead(String) checkRead} method
 *          denies read access to the file.
 */
public static UserPrincipal getOwner(Path path, LinkOption... options) throws IOException {
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class, options);
    if (view == null)
        throw new UnsupportedOperationException();
    return view.getOwner();
}
项目:Java8CN    文件:Files.java   
/**
 * Updates the file owner.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * <p> <b>Usage Example:</b>
 * Suppose we want to make "joe" the owner of a file:
 * <pre>
 *     Path path = ...
 *     UserPrincipalLookupService lookupService =
 *         provider(path).getUserPrincipalLookupService();
 *     UserPrincipal joe = lookupService.lookupPrincipalByName("joe");
 *     Files.setOwner(path, joe);
 * </pre>
 *
 * @param   path
 *          The path to the file
 * @param   owner
 *          The new file owner
 *
 * @return  The path
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkWrite(String) checkWrite}
 *          method denies write access to the file.
 *
 * @see FileSystem#getUserPrincipalLookupService
 * @see java.nio.file.attribute.UserPrincipalLookupService
 */
public static Path setOwner(Path path, UserPrincipal owner)
    throws IOException
{
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class);
    if (view == null)
        throw new UnsupportedOperationException();
    view.setOwner(owner);
    return path;
}
项目:jdk8u_jdk    文件:Files.java   
/**
 * Returns the owner of a file.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * @param   path
 *          The path to the file
 * @param   options
 *          options indicating how symbolic links are handled
 *
 * @return  A user principal representing the owner of the file
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkRead(String) checkRead} method
 *          denies read access to the file.
 */
public static UserPrincipal getOwner(Path path, LinkOption... options) throws IOException {
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class, options);
    if (view == null)
        throw new UnsupportedOperationException();
    return view.getOwner();
}
项目:jdk8u_jdk    文件:Files.java   
/**
 * Updates the file owner.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * <p> <b>Usage Example:</b>
 * Suppose we want to make "joe" the owner of a file:
 * <pre>
 *     Path path = ...
 *     UserPrincipalLookupService lookupService =
 *         provider(path).getUserPrincipalLookupService();
 *     UserPrincipal joe = lookupService.lookupPrincipalByName("joe");
 *     Files.setOwner(path, joe);
 * </pre>
 *
 * @param   path
 *          The path to the file
 * @param   owner
 *          The new file owner
 *
 * @return  The path
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkWrite(String) checkWrite}
 *          method denies write access to the file.
 *
 * @see FileSystem#getUserPrincipalLookupService
 * @see java.nio.file.attribute.UserPrincipalLookupService
 */
public static Path setOwner(Path path, UserPrincipal owner)
    throws IOException
{
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class);
    if (view == null)
        throw new UnsupportedOperationException();
    view.setOwner(owner);
    return path;
}
项目:lookaside_java-1.8.0-openjdk    文件:Files.java   
/**
 * Returns the owner of a file.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * @param   path
 *          The path to the file
 * @param   options
 *          options indicating how symbolic links are handled
 *
 * @return  A user principal representing the owner of the file
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkRead(String) checkRead} method
 *          denies read access to the file.
 */
public static UserPrincipal getOwner(Path path, LinkOption... options) throws IOException {
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class, options);
    if (view == null)
        throw new UnsupportedOperationException();
    return view.getOwner();
}
项目:lookaside_java-1.8.0-openjdk    文件:Files.java   
/**
 * Updates the file owner.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * <p> <b>Usage Example:</b>
 * Suppose we want to make "joe" the owner of a file:
 * <pre>
 *     Path path = ...
 *     UserPrincipalLookupService lookupService =
 *         provider(path).getUserPrincipalLookupService();
 *     UserPrincipal joe = lookupService.lookupPrincipalByName("joe");
 *     Files.setOwner(path, joe);
 * </pre>
 *
 * @param   path
 *          The path to the file
 * @param   owner
 *          The new file owner
 *
 * @return  The path
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkWrite(String) checkWrite}
 *          method denies write access to the file.
 *
 * @see FileSystem#getUserPrincipalLookupService
 * @see java.nio.file.attribute.UserPrincipalLookupService
 */
public static Path setOwner(Path path, UserPrincipal owner)
    throws IOException
{
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class);
    if (view == null)
        throw new UnsupportedOperationException();
    view.setOwner(owner);
    return path;
}
项目:infobip-open-jdk-8    文件:Files.java   
/**
 * Returns the owner of a file.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * @param   path
 *          The path to the file
 * @param   options
 *          options indicating how symbolic links are handled
 *
 * @return  A user principal representing the owner of the file
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkRead(String) checkRead} method
 *          denies read access to the file.
 */
public static UserPrincipal getOwner(Path path, LinkOption... options) throws IOException {
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class, options);
    if (view == null)
        throw new UnsupportedOperationException();
    return view.getOwner();
}
项目:infobip-open-jdk-8    文件:Files.java   
/**
 * Updates the file owner.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * <p> <b>Usage Example:</b>
 * Suppose we want to make "joe" the owner of a file:
 * <pre>
 *     Path path = ...
 *     UserPrincipalLookupService lookupService =
 *         provider(path).getUserPrincipalLookupService();
 *     UserPrincipal joe = lookupService.lookupPrincipalByName("joe");
 *     Files.setOwner(path, joe);
 * </pre>
 *
 * @param   path
 *          The path to the file
 * @param   owner
 *          The new file owner
 *
 * @return  The path
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkWrite(String) checkWrite}
 *          method denies write access to the file.
 *
 * @see FileSystem#getUserPrincipalLookupService
 * @see java.nio.file.attribute.UserPrincipalLookupService
 */
public static Path setOwner(Path path, UserPrincipal owner)
    throws IOException
{
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class);
    if (view == null)
        throw new UnsupportedOperationException();
    view.setOwner(owner);
    return path;
}
项目:jdk8u-dev-jdk    文件:Files.java   
/**
 * Returns the owner of a file.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * @param   path
 *          The path to the file
 * @param   options
 *          options indicating how symbolic links are handled
 *
 * @return  A user principal representing the owner of the file
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkRead(String) checkRead} method
 *          denies read access to the file.
 */
public static UserPrincipal getOwner(Path path, LinkOption... options) throws IOException {
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class, options);
    if (view == null)
        throw new UnsupportedOperationException();
    return view.getOwner();
}
项目:jdk8u-dev-jdk    文件:Files.java   
/**
 * Updates the file owner.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * <p> <b>Usage Example:</b>
 * Suppose we want to make "joe" the owner of a file:
 * <pre>
 *     Path path = ...
 *     UserPrincipalLookupService lookupService =
 *         provider(path).getUserPrincipalLookupService();
 *     UserPrincipal joe = lookupService.lookupPrincipalByName("joe");
 *     Files.setOwner(path, joe);
 * </pre>
 *
 * @param   path
 *          The path to the file
 * @param   owner
 *          The new file owner
 *
 * @return  The path
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkWrite(String) checkWrite}
 *          method denies write access to the file.
 *
 * @see FileSystem#getUserPrincipalLookupService
 * @see java.nio.file.attribute.UserPrincipalLookupService
 */
public static Path setOwner(Path path, UserPrincipal owner)
    throws IOException
{
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class);
    if (view == null)
        throw new UnsupportedOperationException();
    view.setOwner(owner);
    return path;
}
项目:OLD-OpenJDK8    文件:Files.java   
/**
 * Returns the owner of a file.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * @param   path
 *          The path to the file
 * @param   options
 *          options indicating how symbolic links are handled
 *
 * @return  A user principal representing the owner of the file
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkRead(String) checkRead} method
 *          denies read access to the file.
 */
public static UserPrincipal getOwner(Path path, LinkOption... options) throws IOException {
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class, options);
    if (view == null)
        throw new UnsupportedOperationException();
    return view.getOwner();
}
项目:OLD-OpenJDK8    文件:Files.java   
/**
 * Updates the file owner.
 *
 * <p> The {@code path} parameter is associated with a file system that
 * supports {@link FileOwnerAttributeView}. This file attribute view provides
 * access to a file attribute that is the owner of the file.
 *
 * <p> <b>Usage Example:</b>
 * Suppose we want to make "joe" the owner of a file:
 * <pre>
 *     Path path = ...
 *     UserPrincipalLookupService lookupService =
 *         provider(path).getUserPrincipalLookupService();
 *     UserPrincipal joe = lookupService.lookupPrincipalByName("joe");
 *     Files.setOwner(path, joe);
 * </pre>
 *
 * @param   path
 *          The path to the file
 * @param   owner
 *          The new file owner
 *
 * @return  The path
 *
 * @throws  UnsupportedOperationException
 *          if the associated file system does not support the {@code
 *          FileOwnerAttributeView}
 * @throws  IOException
 *          if an I/O error occurs
 * @throws  SecurityException
 *          In the case of the default provider, and a security manager is
 *          installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
 *          or its {@link SecurityManager#checkWrite(String) checkWrite}
 *          method denies write access to the file.
 *
 * @see FileSystem#getUserPrincipalLookupService
 * @see java.nio.file.attribute.UserPrincipalLookupService
 */
public static Path setOwner(Path path, UserPrincipal owner)
    throws IOException
{
    FileOwnerAttributeView view =
        getFileAttributeView(path, FileOwnerAttributeView.class);
    if (view == null)
        throw new UnsupportedOperationException();
    view.setOwner(owner);
    return path;
}