@Override protected void processOptions(LinkedList<String> args) throws IOException { CommandFormat cf = new CommandFormat(2, Integer.MAX_VALUE, "R", null); cf.parse(args); setRecursive(cf.getOpt("R")); String modeStr = args.removeFirst(); try { pp = new ChmodParser(modeStr); } catch (IllegalArgumentException iea) { // TODO: remove "chmod : " so it's not doubled up in output, but it's // here for backwards compatibility... throw new IllegalArgumentException( "chmod : mode '" + modeStr + "' does not match the expected pattern."); } }
@Override protected void processPath(PathData item) throws IOException { short newperms = pp.applyNewPermission(item.stat); if (item.stat.getPermission().toShort() != newperms) { try { item.fs.setPermission(item.path, new FsPermission(newperms)); } catch (IOException e) { LOG.debug("Error changing permissions of " + item, e); throw new IOException( "changing permissions of '" + item + "': " + e.getMessage()); } } } }
/** * Apply permission against specified file and determine what the * new mode would be * @param file File against which to apply mode * @return File's new mode if applied. */ public short applyNewPermission(FileStatus file) { FsPermission perms = file.getPermission(); int existing = perms.toShort(); boolean exeOk = file.isDirectory() || (existing & 0111) != 0; return (short)combineModes(existing, exeOk); } }
/** * Apply permission against specified file and determine what the * new mode would be * @param file File against which to apply mode * @return File's new mode if applied. */ public short applyNewPermission(FileStatus file) { FsPermission perms = file.getPermission(); int existing = perms.toShort(); boolean exeOk = file.isDirectory() || (existing & 0111) != 0; return (short)combineModes(existing, exeOk); } }
@Override protected void processPath(PathData item) throws IOException { short newperms = pp.applyNewPermission(item.stat); if (item.stat.getPermission().toShort() != newperms) { try { item.fs.setPermission(item.path, new FsPermission(newperms)); } catch (IOException e) { LOG.debug("Error changing permissions of " + item, e); throw new IOException( "changing permissions of '" + item + "': " + e.getMessage()); } } } }
ChmodHandler(FileSystem fs, String modeStr) throws IOException { super("chmod", fs); try { pp = new ChmodParser(modeStr); } catch(IllegalArgumentException iea) { patternError(iea.getMessage()); } }
/** * Apply permission against specified file and determine what the * new mode would be * @param file File against which to apply mode * @return File's new mode if applied. */ public short applyNewPermission(FileStatus file) { FsPermission perms = file.getPermission(); int existing = perms.toShort(); boolean exeOk = file.isDirectory() || (existing & 0111) != 0; return (short)combineModes(existing, exeOk); } }
@Override protected void processPath(PathData item) throws IOException { short newperms = pp.applyNewPermission(item.stat); if (item.stat.getPermission().toShort() != newperms) { try { item.fs.setPermission(item.path, new FsPermission(newperms)); } catch (IOException e) { LOG.debug("Error changing permissions of " + item, e); throw new IOException( "changing permissions of '" + item + "': " + e.getMessage()); } } } }
@Override protected void processOptions(LinkedList<String> args) throws IOException { CommandFormat cf = new CommandFormat(2, Integer.MAX_VALUE, "R", null); cf.parse(args); setRecursive(cf.getOpt("R")); String modeStr = args.removeFirst(); try { pp = new ChmodParser(modeStr); } catch (IllegalArgumentException iea) { // TODO: remove "chmod : " so it's not doubled up in output, but it's // here for backwards compatibility... throw new IllegalArgumentException( "chmod : mode '" + modeStr + "' does not match the expected pattern."); } }
/** * Apply permission against specified file and determine what the * new mode would be * @param file File against which to apply mode * @return File's new mode if applied. */ public short applyNewPermission(FileStatus file) { FsPermission perms = file.getPermission(); int existing = perms.toShort(); boolean exeOk = file.isDirectory() || (existing & 0111) != 0; return (short)combineModes(existing, exeOk); } }
@Override protected void processPath(PathData item) throws IOException { short newperms = pp.applyNewPermission(item.stat); if (item.stat.getPermission().toShort() != newperms) { try { item.fs.setPermission(item.path, new FsPermission(newperms)); } catch (IOException e) { LOG.debug("Error changing permissions of " + item, e); throw new IOException( "changing permissions of '" + item + "': " + e.getMessage()); } } } }
@Override protected void processOptions(LinkedList<String> args) throws IOException { CommandFormat cf = new CommandFormat(2, Integer.MAX_VALUE, "R", null); cf.parse(args); setRecursive(cf.getOpt("R")); String modeStr = args.removeFirst(); try { pp = new ChmodParser(modeStr); } catch (IllegalArgumentException iea) { // TODO: remove "chmod : " so it's not doubled up in output, but it's // here for backwards compatibility... throw new IllegalArgumentException( "chmod : mode '" + modeStr + "' does not match the expected pattern."); } }
/** * Apply permission against specified file and determine what the * new mode would be * @param file File against which to apply mode * @return File's new mode if applied. */ public short applyNewPermission(FileStatus file) { FsPermission perms = file.getPermission(); int existing = perms.toShort(); boolean exeOk = file.isDirectory() || (existing & 0111) != 0; return (short)combineModes(existing, exeOk); } }
@Override public void run(FileStatus file, FileSystem srcFs) throws IOException { int newperms = pp.applyNewPermission(file); if (file.getPermission().toShort() != newperms) { try { srcFs.setPermission(file.getPath(), new FsPermission((short)newperms)); } catch (IOException e) { System.err.println(getName() + ": changing permissions of '" + file.getPath() + "':" + e.getMessage()); } } } }
@Override protected void processOptions(LinkedList<String> args) throws IOException { CommandFormat cf = new CommandFormat(2, Integer.MAX_VALUE, "R", null); cf.parse(args); setRecursive(cf.getOpt("R")); String modeStr = args.removeFirst(); try { pp = new ChmodParser(modeStr); } catch (IllegalArgumentException iea) { // TODO: remove "chmod : " so it's not doubled up in output, but it's // here for backwards compatibility... throw new IllegalArgumentException( "chmod : mode '" + modeStr + "' does not match the expected pattern."); } }
/** * Apply permission against specified file and determine what the * new mode would be * @param file File against which to apply mode * @return File's new mode if applied. */ public short applyNewPermission(FileStatus file) { FsPermission perms = file.getPermission(); int existing = perms.toShort(); boolean exeOk = file.isDir() || (existing & 0111) != 0; return (short)combineModes(existing, exeOk); } }
@Override protected void processPath(PathData item) throws IOException { short newperms = pp.applyNewPermission(item.stat); if (item.stat.getPermission().toShort() != newperms) { try { item.fs.setPermission(item.path, new FsPermission(newperms)); } catch (IOException e) { LOG.debug("Error changing permissions of " + item, e); throw new IOException( "changing permissions of '" + item + "': " + e.getMessage()); } } } }
@Override protected void processOptions(LinkedList<String> args) throws IOException { CommandFormat cf = new CommandFormat(2, Integer.MAX_VALUE, "R", null); cf.parse(args); setRecursive(cf.getOpt("R")); String modeStr = args.removeFirst(); try { pp = new ChmodParser(modeStr); } catch (IllegalArgumentException iea) { // TODO: remove "chmod : " so it's not doubled up in output, but it's // here for backwards compatibility... throw new IllegalArgumentException( "chmod : mode '" + modeStr + "' does not match the expected pattern."); } }