@@ -3129,6 +3129,17 @@ mch_isdir(char_u *name)
31293129 return (f & FILE_ATTRIBUTE_DIRECTORY ) != 0 ;
31303130}
31313131
3132+ /*
3133+ * return TRUE if "name" is a directory, NOT a symlink to a directory
3134+ * return FALSE if "name" is not a directory
3135+ * return FALSE for error
3136+ */
3137+ int
3138+ mch_isrealdir (char_u * name )
3139+ {
3140+ return mch_isdir (name ) && !mch_is_symbolic_link (name );
3141+ }
3142+
31323143/*
31333144 * Create directory "name".
31343145 * Return 0 on success, -1 on error.
@@ -3190,10 +3201,10 @@ mch_is_hard_link(char_u *fname)
31903201}
31913202
31923203/*
3193- * Return TRUE if file "fname " is a symbolic link.
3204+ * Return TRUE if "name " is a symbolic link (or a junction) .
31943205 */
31953206 int
3196- mch_is_symbolic_link (char_u * fname )
3207+ mch_is_symbolic_link (char_u * name )
31973208{
31983209 HANDLE hFind ;
31993210 int res = FALSE;
@@ -3204,7 +3215,7 @@ mch_is_symbolic_link(char_u *fname)
32043215 WIN32_FIND_DATAW findDataW ;
32053216
32063217 if (enc_codepage >= 0 && (int )GetACP () != enc_codepage )
3207- wn = enc_to_utf16 (fname , NULL );
3218+ wn = enc_to_utf16 (name , NULL );
32083219 if (wn != NULL )
32093220 {
32103221 hFind = FindFirstFileW (wn , & findDataW );
@@ -3213,7 +3224,7 @@ mch_is_symbolic_link(char_u *fname)
32133224 && GetLastError () == ERROR_CALL_NOT_IMPLEMENTED )
32143225 {
32153226 /* Retry with non-wide function (for Windows 98). */
3216- hFind = FindFirstFile (fname , & findDataA );
3227+ hFind = FindFirstFile (name , & findDataA );
32173228 if (hFind != INVALID_HANDLE_VALUE )
32183229 {
32193230 fileFlags = findDataA .dwFileAttributes ;
@@ -3229,7 +3240,7 @@ mch_is_symbolic_link(char_u *fname)
32293240 else
32303241#endif
32313242 {
3232- hFind = FindFirstFile (fname , & findDataA );
3243+ hFind = FindFirstFile (name , & findDataA );
32333244 if (hFind != INVALID_HANDLE_VALUE )
32343245 {
32353246 fileFlags = findDataA .dwFileAttributes ;
@@ -3241,7 +3252,8 @@ mch_is_symbolic_link(char_u *fname)
32413252 FindClose (hFind );
32423253
32433254 if ((fileFlags & FILE_ATTRIBUTE_REPARSE_POINT )
3244- && reparseTag == IO_REPARSE_TAG_SYMLINK )
3255+ && (reparseTag == IO_REPARSE_TAG_SYMLINK
3256+ || reparseTag == IO_REPARSE_TAG_MOUNT_POINT ))
32453257 res = TRUE;
32463258
32473259 return res ;
@@ -5839,7 +5851,8 @@ mch_delay(
58395851
58405852
58415853/*
5842- * this version of remove is not scared by a readonly (backup) file
5854+ * This version of remove is not scared by a readonly (backup) file.
5855+ * This can also remove a symbolic link like Unix.
58435856 * Return 0 for success, -1 for failure.
58445857 */
58455858 int
@@ -5850,6 +5863,13 @@ mch_remove(char_u *name)
58505863 int n ;
58515864#endif
58525865
5866+ /*
5867+ * On Windows, deleting a directory's symbolic link is done by
5868+ * RemoveDirectory(): mch_rmdir. It seems unnatural, but it is fact.
5869+ */
5870+ if (mch_isdir (name ) && mch_is_symbolic_link (name ))
5871+ return mch_rmdir (name );
5872+
58535873 win32_setattrs (name , FILE_ATTRIBUTE_NORMAL );
58545874
58555875#ifdef FEAT_MBYTE
0 commit comments