本文整理汇总了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;
}
示例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);
}
示例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();
}
示例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");
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
示例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);
}
示例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"));
}
示例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"));
}
示例13: ownerHost
import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
public FileOwnerAttributeView ownerHost() {
return (FileOwnerAttributeView)host;
}
示例14: viewType
import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
@Override
public Class<FileOwnerAttributeView> viewType() {
return FileOwnerAttributeView.class;
}
示例15: view
import java.nio.file.attribute.FileOwnerAttributeView; //导入依赖的package包/类
@Override
public FileOwnerAttributeView view(
FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
return new View(lookup);
}