当前位置: 首页>>代码示例>>Java>>正文


Java FileOwnerAttributeView类代码示例

本文整理汇总了Java中java.nio.file.attribute.FileOwnerAttributeView的典型用法代码示例。如果您正苦于以下问题:Java FileOwnerAttributeView类的具体用法?Java FileOwnerAttributeView怎么用?Java FileOwnerAttributeView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileOwnerAttributeView类属于java.nio.file.attribute包,在下文中一共展示了FileOwnerAttributeView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSupportedFileAttributes

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
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;
}
 
开发者ID:tinyMediaManager,项目名称:tinyMediaManager,代码行数:26,代码来源:FSTest.java

示例2: supportsFileAttributeView

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
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);
}
 
开发者ID:sbridges,项目名称:ephemeralfs,代码行数:17,代码来源:AttributeLookup.java

示例3: getOwnerName

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
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();
}
 
开发者ID:allen12,项目名称:Personifiler,代码行数:18,代码来源:FileSystemWriter.java

示例4: build

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
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");
    }
}
 
开发者ID:sbridges,项目名称:ephemeralfs,代码行数:15,代码来源:FileAttributesViewBuilder.java

示例5: testReadOwner

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
@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);
    }
    
}
 
开发者ID:sbridges,项目名称:ephemeralfs,代码行数:16,代码来源:OwnerFileAttributesTest.java

示例6: addOwner

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
public RWAttributesBuilder addOwner() {
    attributes( "owner", FileOwnerAttributeView.class ).
            attribute( "owner",
                       FunctionE.u( FileOwnerAttributeView::getOwner ),
                       BiConsumerE.u( ( v, p ) -> v.setOwner( (UserPrincipal) p ) ) );

    return this;
}
 
开发者ID:openCage,项目名称:eightyfs,代码行数:9,代码来源:RWAttributesBuilder.java

示例7: roCreate

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
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);
}
 
开发者ID:openCage,项目名称:eightyfs,代码行数:9,代码来源:ReadonlyFS.java

示例8: getView

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
@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;
   }
 
开发者ID:damiencarol,项目名称:jsr203-hadoop,代码行数:15,代码来源:HadoopFileSystem.java

示例9: getFileAttributeViewFileOwnerAttributeView

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
@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());
}
 
开发者ID:damiencarol,项目名称:jsr203-hadoop,代码行数:10,代码来源:TestFiles.java

示例10: supportsFileOwnerAttributeView

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:10,代码来源:FilePersistenceUtils.java

示例11: view

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
@Override
public PosixFileAttributeView view(
    FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
  return new View(
      lookup,
      (BasicFileAttributeView) inheritedViews.get("basic"),
      (FileOwnerAttributeView) inheritedViews.get("owner"));
}
 
开发者ID:google,项目名称:jimfs,代码行数:9,代码来源:PosixAttributeProvider.java

示例12: testView

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
@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"));
}
 
开发者ID:google,项目名称:jimfs,代码行数:13,代码来源:OwnerAttributeProviderTest.java

示例13: ownerHost

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
public FileOwnerAttributeView ownerHost() {
    return (FileOwnerAttributeView)host;
}
 
开发者ID:openCage,项目名称:eightyfs,代码行数:4,代码来源:GuestFileAttributeView.java

示例14: viewType

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
@Override
public Class<FileOwnerAttributeView> viewType() {
  return FileOwnerAttributeView.class;
}
 
开发者ID:google,项目名称:jimfs,代码行数:5,代码来源:OwnerAttributeProvider.java

示例15: view

import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
@Override
public FileOwnerAttributeView view(
    FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
  return new View(lookup);
}
 
开发者ID:google,项目名称:jimfs,代码行数:6,代码来源:OwnerAttributeProvider.java


注:本文中的java.nio.file.attribute.FileOwnerAttributeView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。