[m-rev.] for review: Improve io.dir.m for Java and C#.

Peter Wang novalazy at gmail.com
Fri Aug 26 14:40:38 AEST 2022


On Fri, 26 Aug 2022 12:54:16 +1000 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> 
> 
> On Fri, 26 Aug 2022 12:50:33 +1000 (AEST), Julien Fischer <jfischer at opturion.com> wrote:
> > >     % This will also succeed if the directory already exists
> > >     % and is readable and writable by the current user.
> > >     %
> > > +    % XXX Why does this check for read/writability by the current user?
> > > +    %
> > 
> > Why is that an issue?
> 
> You usually make a directory because you want to put
> files into it. If you don't have permission to do that,
> you should be told just once, when this predicate
> is called, rather than once per file you want to create,
> because the *files* are not responsible for the problem.

It was surprising to me as the predicate is called make_directory
but can fail for other reasons.

Usually you will want to create a file in the directory, but for that
it should check for write and execute access, not read access.

I know we don't care very much about C# or .NET, but the write access
check on directories basically cannot be implemented correctly there.
I made check_file_accessibility err on the side of assuming directories
are writable. Before that, the call to check_file_accessibility would
have make_directory fail mysteriously. (This is when I wrote the XXX.)

Plus the fact that you will get a permission error when you try to
create a file, suggests to me to remove the access check in
make_directory.

There may be cases where you want to try to create a directory but still
continue without write access. (Granted, you would probably ignore the
result of make_directory then.) I don't think it's that far fetched.
With the sandboxing facilities on Linux, it's pretty common to run a
program with limited write access to the file system.

Peter


More information about the reviews mailing list