Exemple #1
0
 private ArrayList<Path> holeLaufwerkeUnix() {
   ArrayList<Path> laufwerksRoot = new ArrayList<>();
   for (FileStore store : FileSystems.getDefault().getFileStores()) {
     if (store.name().contains("/dev/sd")) {
       laufwerksRoot.add(
           Paths.get(store.toString().substring(0, store.toString().indexOf(' '))));
     }
   }
   return laufwerksRoot;
 }
Exemple #2
0
    private ArrayList<Path> holeLaufwerkeWindows() {
      ArrayList<Path> laufwerksRoot = new ArrayList<>();

      Iterable<Path> rootDirectories = FileSystems.getDefault().getRootDirectories();

      for (Path path : rootDirectories) {
        laufwerksRoot.add(path.getRoot());
      }
      return laufwerksRoot;
    }
Exemple #3
0
 private void setOwnership(File dir, String group, String owner) {
   try {
     Path path = dir.toPath();
     UserPrincipalLookupService lookupService =
         FileSystems.getDefault().getUserPrincipalLookupService();
     GroupPrincipal groupPrincipal = lookupService.lookupPrincipalByGroupName(group);
     UserPrincipal userPrincipal = lookupService.lookupPrincipalByName(owner);
     PosixFileAttributeView pfav =
         Files.getFileAttributeView(path, PosixFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
     pfav.setGroup(groupPrincipal);
     pfav.setOwner(userPrincipal);
   } catch (Exception ex) {
     cp.appendln("Unable to set the file group and owner for\n   " + dir);
   }
 }