IS_WRITABLE is path writable

Contents

Inputs

Outputs

function y = is_writable(file)

try
  a = filePermissions(file);
  y = a.Writable;
catch e
  switch e.identifier
    case 'MATLAB:io:filesystem:filePermissions:CannotFindLocation'
      y = false;
    case {'MATLAB:UndefinedFunction', 'Octave:undefined-function'}
      a = file_attributes(file);
      y = ~isempty(a) && (a.UserWrite || a.GroupWrite || a.OtherWrite);
    otherwise
      rethrow(e)
  end
end

end

%!assert (islogical(stdlib.is_writable('.')))