Subject: Re: bug#27986: 26.0.50; 'rename-file' can rename files without confirmation

From: Philipp Stephani <[email-masked]>
Date: Mon, 14 Aug 2017 16:58:04 +0000

Eli Zaretskii <[email-masked]> schrieb am Mo., 14. Aug. 2017 um 17:34 Uhr:

> > From: Paul Eggert <[email-masked]>
> > Cc: Eli Zaretskii <[email-masked]>, [email-masked]
> > Date: Sun, 13 Aug 2017 16:48:59 -0700
> >
> > Getting back to Philipp's original bug report, Apple documentation says
> macOS
> > has a facility like the Linux renameat2 system call (i.e., it's like
> 'renameat'
> > except it can be told to fail if the destination already exists).
> Attached is a
> > proposed patch to use this facility, which means that the
> case-insensitivity
> > test would no longer need to be done in macOS. If there's some way to
> implement
> > renameat_noreplace on MS-Windows we could get rid of the
> case-insensitivity test
> > there too.
>
> There's nothing easier than implementing renameat_noreplace on
> MS-Windows, since the underlying system call does that by default, and
> it's emulating the Posix behavior that requires complications.
>

You might be able to eliminate these complications by calling MoveFileExW
with MOVEFILE_REPLACE_EXISTING.