Improve rename-file behavior on macOS
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.
This commit is contained in:
parent
4fe9a9efcf
commit
13a846823a
2 changed files with 6 additions and 2 deletions
|
@ -2259,12 +2259,14 @@ This is what happens in interactive use with M-x. */)
|
|||
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);
|
||||
|
|
|
@ -2693,11 +2693,13 @@ renameat_noreplace (int srcfd, char const *src, int dstfd, char const *dst)
|
|||
{
|
||||
#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
|
||||
|
|
Loading…
Add table
Reference in a new issue