private static String toExceptionMessage(String user, Mode.Bits bits, String path, Inode inode) { StringBuilder sb = new StringBuilder().append("user=").append(user).append(", ").append("access=").append(bits) .append(", ").append("path=").append(path).append(": ").append("failed at ") .append(inode.getName().equals("") ? "/" : inode.getName()).append(", inode owner=") .append(inode.getOwner()).append(", inode group=").append(inode.getGroup()) .append(", inode mode=").append(new Mode(inode.getMode()).toString()); return sb.toString(); } }
/** * Formats digital representation of a model as a human-readable string. * * @param mode file mode * @param directory if the mode corresponds to a directory * @param hasExtended true if extended acls exist * @return human-readable version of the given mode */ public static String formatMode(short mode, boolean directory, boolean hasExtended) { StringBuilder str = new StringBuilder(); if (directory) { str.append("d"); } else { str.append("-"); } str.append(new Mode(mode).toString()); if (hasExtended) { str.append("+"); } return str.toString(); }
@Override public void setMode(String path, short mode) throws IOException { path = stripPath(path); String posixPerm = new Mode(mode).toString(); FileUtils.changeLocalFilePermission(path, posixPerm); }
/** * Tests the {@link Mode#toString()} method. */ @Test public void toStringTest() { assertEquals("rwxrwxrwx", new Mode((short) 0777).toString()); assertEquals("rw-r-----", new Mode((short) 0640).toString()); assertEquals("rw-------", new Mode((short) 0600).toString()); assertEquals("---------", new Mode((short) 0000).toString()); }
/** * Formats digital representation of a model as a human-readable string. * * @param mode file mode * @param directory if the mode corresponds to a directory * @return human-readable version of the given mode */ public static String formatMode(short mode, boolean directory) { StringBuilder str = new StringBuilder(); if (directory) { str.append("d"); } else { str.append("-"); } str.append(new Mode(mode).toString()); return str.toString(); }
private static String toExceptionMessage(String user, Mode.Bits bits, String path, Inode<?> inode) { StringBuilder sb = new StringBuilder().append("user=").append(user).append(", ").append("access=").append(bits) .append(", ").append("path=").append(path).append(": ").append("failed at ") .append(inode.getName().equals("") ? "/" : inode.getName()).append(", inode owner=") .append(inode.getOwner()).append(", inode group=").append(inode.getGroup()) .append(", inode mode=").append(new Mode(inode.getMode()).toString()); return sb.toString(); } }