From: Eli Zaretskii Date: Sat, 13 Jul 2024 12:52:38 +0000 (+0300) Subject: Fix renaming symlinks on MS-Windows X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=82e9a485c5438543a5415ae4c1d870a30d17f605;p=emacs.git Fix renaming symlinks on MS-Windows * src/w32.c (sys_rename_replace): Handle renames of a symlink. This makes 'wdired-tests' succeed on MS-Windows. (cherry picked from commit 5389b6a856b39427846e38b06fa398bafc04836a) --- diff --git a/src/w32.c b/src/w32.c index ab45ae8ec6b..6dcbbbcc61b 100644 --- a/src/w32.c +++ b/src/w32.c @@ -4761,6 +4761,15 @@ sys_rename_replace (const char *oldname, const char *newname, BOOL force) strcpy (temp, map_w32_filename (oldname, NULL)); + /* 'rename' (which calls MoveFileW) renames the _target_ of the + symlink, which is different from Posix behavior and not what we + want here. So in that case we pretend this is a cross-device move, + for which Frename_file already has a workaround. */ + if (is_symlink (temp)) + { + errno = EXDEV; + return -1; + } /* volume_info is set indirectly by map_w32_filename. */ oldname_dev = volume_info.serialnum;