Problem reported by Philipp Stephani (Bug#27986).
* src/fileio.c (Frename_file):
Worry about file name case sensitivity only if CYGWIN or DOS_NT.
* src/sysdep.c (renameat_noreplace): Use renameatx_np on macOS,
since this provides the necessary atomicity guarantees.
not worry whether NEWNAME exists or whether it is a directory, as
it is already another name for FILE. */
bool case_only_rename = false;
+#if defined CYGWIN || defined DOS_NT
if (!NILP (Ffile_name_case_insensitive_p (file)))
{
newname = Fexpand_file_name (newname, Qnil);
case_only_rename = !NILP (Fstring_equal (Fdowncase (file),
Fdowncase (newname)));
}
+#endif
if (!case_only_rename)
newname = expand_cp_target (Fdirectory_file_name (file), newname);
{
#if defined SYS_renameat2 && defined RENAME_NOREPLACE
return syscall (SYS_renameat2, srcfd, src, dstfd, dst, RENAME_NOREPLACE);
+#elif defined RENAME_EXCL
+ return renameatx_np (srcfd, src, dstfd, dst, RENAME_EXCL);
#else
-#ifdef WINDOWSNT
+# ifdef WINDOWSNT
if (srcfd == AT_FDCWD && dstfd == AT_FDCWD)
return sys_rename_replace (src, dst, 0);
-#endif
+# endif
errno = ENOSYS;
return -1;
#endif