From: Daniel Lehman Subject: [PATCH 2/5] kernel32: Add support for deleting junction points with RemoveDirectory. Message-Id: <340ac80c090044029d6b4dd45918886b@RED-INF-MXMB-P4.esri.com> Date: Thu, 16 Nov 2017 00:09:53 +0000 From 3bc7f444be1ec36bab305771c172341828d28f36 Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Mon, 13 Nov 2017 17:10:49 -0800 Subject: [PATCH 2/5] kernel32: Add support for deleting junction points with RemoveDirectory. Signed-off-by: Daniel Lehman --- dlls/kernel32/path.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c index a389743..073ad81 100644 --- a/dlls/kernel32/path.c +++ b/dlls/kernel32/path.c @@ -1653,6 +1653,7 @@ BOOL WINAPI CreateDirectoryExW( LPCWSTR template, LPCWSTR path, LPSECURITY_ATTRI */ BOOL WINAPI RemoveDirectoryW( LPCWSTR path ) { + FILE_BASIC_INFORMATION info; OBJECT_ATTRIBUTES attr; UNICODE_STRING nt_name; ANSI_STRING unix_name; @@ -1686,15 +1687,23 @@ BOOL WINAPI RemoveDirectoryW( LPCWSTR path ) } status = wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, FALSE ); - RtlFreeUnicodeString( &nt_name ); if (status != STATUS_SUCCESS) { SetLastError( RtlNtStatusToDosError(status) ); + RtlFreeUnicodeString( &nt_name ); NtClose( handle ); return FALSE; } - if (!(ret = (rmdir( unix_name.Buffer ) != -1))) FILE_SetDosError(); + status = NtQueryAttributesFile( &attr, &info ); + if (status == STATUS_SUCCESS && (info.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) && + (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + ret = (unlink( unix_name.Buffer ) != -1); + else + ret = (rmdir( unix_name.Buffer ) != -1); + if (!ret) FILE_SetDosError(); + + RtlFreeUnicodeString( &nt_name ); RtlFreeAnsiString( &unix_name ); NtClose( handle ); return ret; -- 1.9.5