[KERNEL32]
[reactos.git] / reactos / dll / win32 / kernel32 / file / cnotify.c
index 59f6165..37814a1 100644 (file)
@@ -9,10 +9,13 @@
  *                  Created 01/11/98
  */
 
+/* INCLUDES *****************************************************************/
+
 #include <k32.h>
-#include <wine/debug.h>
+#define NDEBUG
+#include <debug.h>
 
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+/* FUNCTIONS ****************************************************************/
 
 /*
  * @implemented
@@ -36,20 +39,30 @@ FindCloseChangeNotification (HANDLE hChangeHandle)
  */
 HANDLE
 WINAPI
-FindFirstChangeNotificationA (
-       LPCSTR  lpPathName,
-       BOOL    bWatchSubtree,
-       DWORD   dwNotifyFilter
-       )
+FindFirstChangeNotificationA(IN LPCSTR lpPathName,
+                             IN BOOL bWatchSubtree,
+                             IN DWORD dwNotifyFilter)
 {
-       PWCHAR PathNameW;
-
-   if (!(PathNameW = FilenameA2W(lpPathName, FALSE)))
-      return INVALID_HANDLE_VALUE;
-
-   return FindFirstChangeNotificationW (PathNameW ,
-                                               bWatchSubtree,
-                                               dwNotifyFilter);
+    NTSTATUS Status;
+    ANSI_STRING PathNameString;
+
+    RtlInitAnsiString(&PathNameString, lpPathName);
+    Status = RtlAnsiStringToUnicodeString(&(NtCurrentTeb()->StaticUnicodeString), &PathNameString, FALSE);
+    if (!NT_SUCCESS(Status))
+    {
+        if (Status != STATUS_BUFFER_OVERFLOW)
+        {
+            SetLastError(ERROR_FILENAME_EXCED_RANGE);
+        }
+        else
+        {
+            BaseSetLastNTError(Status);
+        }
+        return INVALID_HANDLE_VALUE;
+    }
+
+    return FindFirstChangeNotificationW(NtCurrentTeb()->StaticUnicodeString.Buffer,
+                                        bWatchSubtree, dwNotifyFilter);
 }
 
 
@@ -220,7 +233,7 @@ ReadDirectoryChangesW(
       EventHandle,
       IoApcRoutine,
       CompletionRoutine, /* ApcContext */
-      lpOverlapped ? (PIO_STATUS_BLOCK)lpOverlapped->Internal : &IoStatus,
+      lpOverlapped ? (PIO_STATUS_BLOCK) lpOverlapped : &IoStatus,
       lpBuffer,
       nBufferLength,
       dwNotifyFilter,