SET_PERMISSIONS set path permissions

optional: mex

Contents

Inputs

Outputs

function ok = set_permissions(path, readable, writable, executable)
arguments
  path (1,1) string {mustBeFile}
  readable (1,1) int8
  writable (1,1) int8
  executable (1,1) int8
end

ok = false;

try
  p = filePermissions(path);
catch e
  switch e.identifier
    case "MATLAB:UndefinedFunction", error("buildtool mex")
    case "MATLAB:io:filesystem:filePermissions:CannotFindLocation", return
    otherwise, rethrow(e)
  end
end

ok = true;

if readable ~= 0
  ok = ok && setPermissions(p, "Readable", readable > 0);
end
if writable ~= 0
  ok = ok && setPermissions(p, "Writable", writable > 0);
end
if executable ~= 0
  ok = ok && setPermissions(p, "Executable", executable > 0);
end

end