[m-rev.] for review: Allow remove_file to remove an empty dir on C# backend.

Julien Fischer jfischer at opturion.com
Fri Aug 26 12:44:08 AEST 2022


On Thu, 25 Aug 2022, Peter Wang wrote:

> Do we want to define remove_file to removing empty directories?

The documentation for remove_file_recursively suggests that was
intended to be the case.

     % Unlike remove_file, this predicate will attempt to remove non-empty
     % directories (recursively). If it fails, some of the directory
     % elements may already have been removed.

> -----
>
> library/io.file.m:
>    Change the C# implementation of remove_file to delete empty
>    directories.
>
>    Document that remove_file may delete empty directories.
>
> diff --git a/library/io.file.m b/library/io.file.m
> index a9a86fb8c..8401a7e36 100644
> --- a/library/io.file.m
> +++ b/library/io.file.m
> @@ -28,6 +28,10 @@
>     % fails. If FileName names a file that is currently open, the behaviour
>     % is implementation-dependent.
>     %
> +    % If FileName names a directory, the behavior is currently
> +    % implementation-dependent. On most platforms, an empty directory will be
> +    % deleted.
> +    %

Is the only platform where it is now not delete any empty directory
Windows (i.e the XXX below)?

These documentation changes should be reflect in the obsolete version in
io.m.

> :- pred remove_file(string::in, io.res::out, io::di, io::uo) is det.
>
>     % remove_file_recursively(FileName, Result, !IO) attempts to remove
> @@ -243,6 +247,7 @@ remove_file(FileName, Result, !IO) :-
> "
>     int rc;
> #ifdef MR_WIN32
> +    // XXX _wremove will not delete an empty directory; _wrmdir does that.
>     rc = _wremove(ML_utf8_to_wide(FileName));
> #else

That looks fine otherwise.

Julien.


More information about the reviews mailing list