@Override public UserPrincipal getOwner() throws IOException { return ownerView.getOwner(); }
@Override public void setOwner(UserPrincipal owner) throws IOException { ownerView.setOwner(owner); } }
@Override public UserPrincipal getOwner() throws IOException { return ownerView.getOwner(); }
@Override public void setOwner(UserPrincipal owner) throws IOException { ownerView.setOwner(owner); } }
try { FileOwnerAttributeView view = Files.getFileAttributeView(file, FileOwnerAttributeView.class); attributes.put(FILE_OWNER_ATTRIBUTE, view.getOwner().getName()); } catch (Exception ignore) {
@Override public void setOwner(UserPrincipal owner) throws IOException { ownerView.setOwner(owner); } }
try { FileOwnerAttributeView view = Files.getFileAttributeView(filePath, FileOwnerAttributeView.class); attributes.put(FILE_OWNER_ATTRIBUTE, view.getOwner().getName()); } catch (Exception ignore) {
@Override public void setOwner(UserPrincipal owner) throws IOException { ownerView.setOwner(owner); } }
/** * Determines the 'owner' of the file. */ public static String getOwnerName(final File file) { try { final Path path = Paths.get(file.getAbsolutePath()); final FileOwnerAttributeView ownerAttributeView = Files.getFileAttributeView(path, FileOwnerAttributeView.class); return ownerAttributeView != null ? ownerAttributeView.getOwner().getName() : null; } catch(Exception e) { logger.warn("Failed to determine 'owner' of {}: {}", file, e.getMessage()); return null; } }
@Override public void writeAttribute(Object value, MemoryEntry entry) throws IOException { entry.getFileAttributeView(FileOwnerAttributeView.class).setOwner((UserPrincipal) value); }
@Override public UserPrincipal getOwner() throws IOException { return ownerView.getOwner(); }
@Override public void setOwner( UserPrincipal owner ) throws IOException { ownerHost().setOwner( owner ); }
@Override public UserPrincipal getOwner() throws IOException { return ownerView.getOwner(); }
private Consumer<Path> updateOwner(final UserPrincipal owner) { return path -> { try { Files.getFileAttributeView(path, FileOwnerAttributeView.class).setOwner(owner); getLog().debug("Updating owner of" + path); } catch (IOException e) { throw new RuntimeException("Unable to update YAML file owner", e); } }; } }
Path path = Paths.get("C:/Users/Thomas/workspace_eclipse_java/Test/javassist-3.12.1.GA.jar"); FileOwnerAttributeView owner= Files.getFileAttributeView(path, FileOwnerAttributeView.class); System.out.println("owner: " + owner.getOwner().getName());
@Override public void setOwner(UserPrincipal owner) throws ModeException { FileOwnerAttributeView view = Files.getFileAttributeView(path, FileOwnerAttributeView.class); try { view.setOwner(owner); } catch (IOException e) { throw new ModeException(this, e); } }
@Override public UserPrincipal getOwner() throws IOException { return ownerHost().getOwner(); }