case STICKY_CHAR:
sticky = true;
break;
default:
throw new SyntaxException("Unrecognised mode char '" + c + "'");
}
}
final char whoose[];
if(whoPerm[0].length() > 0) {
whoose = whoPerm[0].toCharArray();
} else {
whoose = new char[]{ ALL_CHAR };
}
for(final char c: whoose) {
switch(c) {
case ALL_CHAR:
final int newMode = (perm << 6) | (perm << 3) | perm | (sticky ? (STICKY << 9) : 0) | (uidgid ? ((SET_UID | SET_GID) << 9) : 0);
if(clause.indexOf("+") > -1) {
setMode(getMode() | newMode);
} else if(clause.indexOf("-") > -1) {
setMode(getMode() & ~newMode);
} else if(clause.indexOf("=") > -1) {
setMode(newMode);
}
break;
case USER_CHAR:
if(clause.indexOf("+") > -1) {
setOwnerMode(getOwnerMode() | perm);
if(uidgid) {
setSetUid(true);
}
} else if(clause.indexOf("-") > -1) {
setOwnerMode(getOwnerMode() & ~perm);
if(uidgid) {
setSetUid(false);
}
} else if(clause.indexOf("=") > -1) {
setOwnerMode(perm);
if(uidgid) {
setSetUid(true);
}
}
break;
case GROUP_CHAR:
if(clause.indexOf("+") > -1) {
setGroupMode(getGroupMode() | perm);
if(uidgid) {
setSetGid(true);
}
} else if(clause.indexOf("-") > -1) {
setGroupMode(getGroupMode() & ~perm);
if(uidgid) {
setSetGid(false);
}
} else if(clause.indexOf("=") > -1) {
setGroupMode(perm);
if(uidgid) {
setSetGid(true);
}
}
break;
case OTHER_CHAR:
if(clause.indexOf("+") > -1) {
setOtherMode(getOtherMode() | perm);
if(sticky) {
setSticky(true);
}
} else if(clause.indexOf("-") > -1) {
setOtherMode(getOtherMode() & ~perm);
if(sticky) {
setSticky(false);
}
} else if(clause.indexOf("=") > -1) {
setOtherMode(perm);
if(sticky) {
setSticky(true);
}
}
break;
default:
throw new SyntaxException("Unrecognised mode char '" + c + "'");
}
}
perm = 0;
uidgid = false;