[m-rev.] for post-commit review: don't "clean" files as if they were directories
Julien Fischer
jfischer at opturion.com
Tue Sep 30 22:01:25 AEST 2025
On Tue, 30 Sept 2025 at 17:11, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
> Don't try to remove directories for mmc --make *.clean.
> diff --git a/compiler/make.util.m b/compiler/make.util.m
...
> index 9133ab8e3..9788aae58 100644
> --- a/compiler/make.util.m
> +++ b/compiler/make.util.m
> @@ -278,7 +278,7 @@ remove_file_for_make(ProgressStream, Globals, VerboseOption, FileName,
> option_set_two_part_msg(Globals, VerboseOption,
> "Removing", FileName, RemovingMsg),
> maybe_write_msg(ProgressStream, RemovingMsg, !IO),
> - io.file.remove_file_recursively(FileName, _, !IO),
> + io.file.remove_file(FileName, _, !IO),
> FileTimestampMap0 = make_info_get_file_timestamp_map(!.Info),
> map.delete(FileName, FileTimestampMap0, FileTimestampMap),
> make_info_set_file_timestamp_map(FileTimestampMap, !Info),
> diff --git a/library/io.file.m b/library/io.file.m
> index e6b8c30d4..fb09ab39b 100644
> --- a/library/io.file.m
> +++ b/library/io.file.m
> @@ -23,22 +23,28 @@
> %
> % File handling predicates.
> %
> +% NOTE_TO_IMPLEMENTORS We should add an "unlink_file" predicate that
> +% NOTE_TO_IMPLEMENTORS guarantees, on all platforms, that it deletes
> +% NOTE_TO_IMPLEMENTORS only regular files. Unfortunately, I (zs) don't know
> +% NOTE_TO_IMPLEMENTORS how to implement that for C# and Java.
In C# File.Delete will do that and throw an UnauthorizedAccessException if the
path passed as its argument is a directory.
In Java, you would need to check if the file is a directory before attempting
the delete operation.
Julien.
More information about the reviews
mailing list