code: 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);
    }
docs: 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.