Skip to content

Commit

Permalink
Added permission error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Guichaguri committed Jun 22, 2018
1 parent a7b20ce commit 361f4ce
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,13 @@ public void rename(File from, File to) throws IOException {

@Override
public void chmod(File file, int perms) throws IOException {
file.setReadable(Utils.hasPermission(perms, Utils.CAT_OWNER + Utils.TYPE_READ), true);
file.setWritable(Utils.hasPermission(perms, Utils.CAT_OWNER + Utils.TYPE_WRITE), true);
file.setExecutable(Utils.hasPermission(perms, Utils.CAT_OWNER + Utils.TYPE_EXECUTE), true);
boolean read = Utils.hasPermission(perms, Utils.CAT_OWNER + Utils.TYPE_READ);
boolean write = Utils.hasPermission(perms, Utils.CAT_OWNER + Utils.TYPE_WRITE);
boolean execute = Utils.hasPermission(perms, Utils.CAT_OWNER + Utils.TYPE_EXECUTE);

if(!file.setReadable(read, true)) throw new IOException("Couldn't update the readable permission");
if(!file.setWritable(write, true)) throw new IOException("Couldn't update the writable permission");
if(!file.setExecutable(execute, true)) throw new IOException("Couldn't update the executable permission");
}

@Override
Expand Down

0 comments on commit 361f4ce

Please sign in to comment.