[3/3] kernel32: Reimplement RemoveDirectory.

Dmitry Timoshkov dmitry at baikal.ru
Mon Feb 10 03:47:21 CST 2014


This implementation uses same aproach as DeleteFile does and allows
to keep directory until last handle to it is closed.
---
 dlls/kernel32/path.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index 09fb04b..28b25cc 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -1589,11 +1589,9 @@ BOOL WINAPI RemoveDirectoryW( LPCWSTR path )
 {
     OBJECT_ATTRIBUTES attr;
     UNICODE_STRING nt_name;
-    ANSI_STRING unix_name;
     IO_STATUS_BLOCK io;
     NTSTATUS status;
     HANDLE handle;
-    BOOL ret = FALSE;
 
     TRACE( "%s\n", debugstr_w(path) );
 
@@ -1611,21 +1609,16 @@ BOOL WINAPI RemoveDirectoryW( LPCWSTR path )
 
     status = NtOpenFile( &handle, DELETE, &attr, &io,
                          FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
-                         FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
-    if (status == STATUS_SUCCESS)
-        status = wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, FALSE );
-    RtlFreeUnicodeString( &nt_name );
+                         FILE_DELETE_ON_CLOSE | FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
+    if (status == STATUS_SUCCESS) status = NtClose( handle );
 
-    if (status != STATUS_SUCCESS)
+    RtlFreeUnicodeString( &nt_name );
+    if (status)
     {
         SetLastError( RtlNtStatusToDosError(status) );
         return FALSE;
     }
-
-    if (!(ret = (rmdir( unix_name.Buffer ) != -1))) FILE_SetDosError();
-    RtlFreeAnsiString( &unix_name );
-    NtClose( handle );
-    return ret;
+    return TRUE;
 }
 
 
-- 
1.8.5.3




More information about the wine-patches mailing list