Mike McCormack : kernel32: Implement FindFirstChangeNotification with NtNotifyChangeDirectoryFile.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jan 27 05:59:11 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 53dab1520055b089f1b40d3164245b7890843294
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=53dab1520055b089f1b40d3164245b7890843294

Author: Mike McCormack <mike at codeweavers.com>
Date:   Fri Jan 27 12:54:31 2006 +0100

kernel32: Implement FindFirstChangeNotification with NtNotifyChangeDirectoryFile.

---

 dlls/kernel/change.c |   49 ++++++++++++++++++-------------------------------
 1 files changed, 18 insertions(+), 31 deletions(-)

diff --git a/dlls/kernel/change.c b/dlls/kernel/change.c
index d899f27..1f1b162 100644
--- a/dlls/kernel/change.c
+++ b/dlls/kernel/change.c
@@ -58,14 +58,14 @@ HANDLE WINAPI FindFirstChangeNotificatio
     OBJECT_ATTRIBUTES attr;
     IO_STATUS_BLOCK io;
     NTSTATUS status;
-    HANDLE file, ret = INVALID_HANDLE_VALUE;
+    HANDLE handle = INVALID_HANDLE_VALUE;
 
     TRACE( "%s %d %lx\n", debugstr_w(lpPathName), bWatchSubtree, dwNotifyFilter );
 
     if (!RtlDosPathNameToNtPathName_U( lpPathName, &nt_name, NULL, NULL ))
     {
         SetLastError( ERROR_PATH_NOT_FOUND );
-        return ret;
+        return handle;
     }
 
     attr.Length = sizeof(attr);
@@ -75,7 +75,7 @@ HANDLE WINAPI FindFirstChangeNotificatio
     attr.SecurityDescriptor = NULL;
     attr.SecurityQualityOfService = NULL;
 
-    status = NtOpenFile( &file, SYNCHRONIZE, &attr, &io,
+    status = NtOpenFile( &handle, SYNCHRONIZE, &attr, &io,
                          FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
                          FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
     RtlFreeUnicodeString( &nt_name );
@@ -83,21 +83,18 @@ HANDLE WINAPI FindFirstChangeNotificatio
     if (status != STATUS_SUCCESS)
     {
         SetLastError( RtlNtStatusToDosError(status) );
-        return ret;
+        return INVALID_HANDLE_VALUE;
     }
 
-    SERVER_START_REQ( read_directory_changes )
+    status = NtNotifyChangeDirectoryFile( handle, NULL, NULL, NULL, &io,
+                                          NULL, 0, dwNotifyFilter, bWatchSubtree );
+    if (status != STATUS_PENDING)
     {
-        req->handle     = file;
-        req->event      = NULL;
-        req->filter     = dwNotifyFilter;
-        status = wine_server_call( req );
-        if (status == STATUS_PENDING)
-            ret = file;
+        NtClose( handle );
+        SetLastError( RtlNtStatusToDosError(status) );
+        return INVALID_HANDLE_VALUE;
     }
-    SERVER_END_REQ;
-
-    return ret;
+    return handle;
 }
 
 /****************************************************************************
@@ -105,29 +102,19 @@ HANDLE WINAPI FindFirstChangeNotificatio
  */
 BOOL WINAPI FindNextChangeNotification( HANDLE handle )
 {
-    BOOL ret = FALSE;
+    IO_STATUS_BLOCK io;
     NTSTATUS status;
 
     TRACE("%p\n",handle);
 
-    if (!handle)
-    {
-        SetLastError( ERROR_INVALID_HANDLE );
-        return ret;
-    }
-
-    SERVER_START_REQ( read_directory_changes )
+    status = NtNotifyChangeDirectoryFile( handle, NULL, NULL, NULL, &io,
+                                          NULL, 0, FILE_NOTIFY_CHANGE_SIZE, 0 );
+    if (status != STATUS_PENDING)
     {
-        req->handle     = handle;
-        req->event      = NULL;
-        req->filter     = FILE_NOTIFY_CHANGE_SIZE; /* valid but ignored */
-        status = wine_server_call( req );
-        if (status == STATUS_PENDING)
-            ret = TRUE;
+        SetLastError( RtlNtStatusToDosError(status) );
+        return FALSE;
     }
-    SERVER_END_REQ;
-
-    return ret;
+    return TRUE;
 }
 
 /****************************************************************************




More information about the wine-cvs mailing list