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


Java PosixFilePermissions.toString方法代码示例

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


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

示例1: getPermission

import java.nio.file.attribute.PosixFilePermissions; //导入方法依赖的package包/类
@Override
public Permission getPermission() {
    if(FileSystems.getDefault().supportedFileAttributeViews().contains("posix")) {
        final BasicFileAttributes attributes;
        try {
            return new LocalPermission(PosixFilePermissions.toString(Files.readAttributes(Paths.get(path), PosixFileAttributes.class, LinkOption.NOFOLLOW_LINKS).permissions()));
        }
        catch(IOException e) {
            return Permission.EMPTY;
        }
    }
    return Permission.EMPTY;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:14,代码来源:LocalAttributes.java

示例2: resetPosixPermissions

import java.nio.file.attribute.PosixFilePermissions; //导入方法依赖的package包/类
private boolean resetPosixPermissions(Path file, FileState fileState, PosixFileAttributes posixFileAttributes) throws IOException {
    String permissions = PosixFilePermissions.toString(posixFileAttributes.permissions());
    String previousPermissions = getAttribute(fileState, FileAttribute.PosixFilePermissions);
    if (previousPermissions != null && !Objects.equals(permissions, previousPermissions)) {
        Set<PosixFilePermission> permissionSet = PosixFilePermissions.fromString(previousPermissions);
        Files.getFileAttributeView(file, PosixFileAttributeView.class).setPermissions(permissionSet);
        Logger.out.printf("Set permissions: %s \t%s -> %s%n", fileState.getFileName(), permissions, previousPermissions);
        return true;
    }
    return false;
}
 
开发者ID:evrignaud,项目名称:fim,代码行数:12,代码来源:ResetFileAttributesCommand.java

示例3: compare

import java.nio.file.attribute.PosixFilePermissions; //导入方法依赖的package包/类
private void compare(TestFile file) throws KMRuntimeException, IOException {
    String path = file.path;
    Path realPath = file.realPath;
    FileInfo fileInfo = host.getFileInfo(path);
    Map<String, Object> attrs = Files.readAttributes(realPath, "*", NOFOLLOW_LINKS);
    assertNotNull(fileInfo);
    assertEquals(fileInfo.getPath(), path);
    assertEquals(fileInfo.getGroup(), fileGroup);
    assertEquals(fileInfo.getOwner(), fileUser);
    if (Files.isDirectory(realPath, NOFOLLOW_LINKS)) {
        assertEquals(fileInfo.getType(), DIRECTORY);
        assertNull(fileInfo.getLinkTarget());
    } else if (Files.isRegularFile(realPath, NOFOLLOW_LINKS)) {
        assertEquals(fileInfo.getType(), FILE);
        assertNull(fileInfo.getLinkTarget());
        assertEquals(fileInfo.getSize(), Files.size(realPath));
    } else if (Files.isSymbolicLink(realPath)) {
        assertEquals(fileInfo.getType(), SYMLINK);
        assertEquals(fileInfo.getLinkTarget(), file.target);
    } else {
        assertEquals(fileInfo.getType(), OTHER);
        assertNull(fileInfo.getLinkTarget());
    }
    String expectedPerms = PosixFilePermissions.toString(Files.getPosixFilePermissions(realPath, NOFOLLOW_LINKS));
    if (host instanceof SshHost) {
        expectedPerms = (fileInfo.getType() == DIRECTORY ? "d" : "-") + expectedPerms;
    }
    assertEquals(fileInfo.getPermissions(), expectedPerms);
    assertEquals(fileInfo.getModified(), ((FileTime) attrs.get("lastModifiedTime")).toMillis());
}
 
开发者ID:Kloudtek,项目名称:kloudmake,代码行数:31,代码来源:AbstractHostTests.java

示例4: getPermissions

import java.nio.file.attribute.PosixFilePermissions; //导入方法依赖的package包/类
@Override
public String getPermissions() throws IOException {
  return PosixFilePermissions.toString(Files.getPosixFilePermissions(file.toPath()));
}
 
开发者ID:apache,项目名称:twill,代码行数:5,代码来源:LocalLocation.java

示例5: getPermissions

import java.nio.file.attribute.PosixFilePermissions; //导入方法依赖的package包/类
public String getPermissions(Path path) {
    return PosixFilePermissions.toString(getAttributes(path).permissions());
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:4,代码来源:FileSystem.java

示例6: preVisitDirectory

import java.nio.file.attribute.PosixFilePermissions; //导入方法依赖的package包/类
@Override public FileVisitResult preVisitDirectory(Path directory, BasicFileAttributes basicAttribs) throws IOException
{
  boolean skip = false;
  for(int i = 0; i < excludes.size(); i++)
  {
    if(directory.toString().matches(excludes.get(i)))
    skip = true;
  }
  if(skip)
  {
    System.out.println("Ignored excluded directory: " + directory);
    return FileVisitResult.CONTINUE;
  }

  if(pathExists(directory))
  {
    System.out.println("Skipping existing directory: " + directory);
    return FileVisitResult.CONTINUE;
  }

  System.out.print("Importing directory: " + directory);

  PosixFileAttributes posixAttribs = Files.readAttributes(directory, PosixFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
  SimpleDateFormat timestampFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
  Date currentTime = new Date();
  String timestamp = timestampFormat.format(currentTime);
  System.out.println(" " + timestamp);
  Set<PosixFilePermission> posixPerms = posixAttribs.permissions();
  String perms = PosixFilePermissions.toString(posixPerms);

  String inode = posixAttribs.fileKey().toString();
  Pattern p = Pattern.compile("\\=(\\d+)\\)");
  Matcher m = p.matcher(inode);
  m.find();
  inode = m.group(1);

  long mtimeStamp = posixAttribs.lastModifiedTime().toMillis();

  if(posixAttribs.isSymbolicLink())
    System.out.println(Files.readSymbolicLink(directory).toString());

  // Log this to file once in production
  //System.out.println("Properties of directory: " + directory);
  //System.out.println(inode + " " + perms + " " + posixAttribs.owner().getName() + ":" + posixAttribs.group().getName() + " " + posixAttribs.size() + " " + calcMtime(mtimeStamp) + "\n");

  CloneFilesystem.Record entry = new CloneFilesystem.Record();
  entry.path = directory.toString();
  entry.name = new File(entry.path).getName();
  entry.inode = Long.parseLong(inode);
  entry.type = determineType(directory, posixAttribs);
  entry.mode = calculateOctalPerms(perms);
  entry.linkCount = 1;                                         // link count is currently broken; set a default of one (itself)
  entry.uid = users.get(posixAttribs.owner().getName());       // use containsKey() if this causes a null pointer exception
  entry.gid = groups.get(posixAttribs.group().getName());      // same as above
  entry.atime = posixAttribs.lastAccessTime().toMillis();
  entry.ctime = posixAttribs.creationTime().toMillis();
  entry.mtime = posixAttribs.lastModifiedTime().toMillis();
  if(posixAttribs.isSymbolicLink())
    entry.link = Files.readSymbolicLink(directory).toString();
  else
    entry.link = null;
  entry.data = "";
  writeDatabase(entry, false, true);

  return FileVisitResult.CONTINUE;
}
 
开发者ID:ldilley,项目名称:linulator,代码行数:67,代码来源:CloneFilesystem.java


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