init. change notification work

svn path=/trunk/; revision=4416
This commit is contained in:
Gunnar Dalsnes 2003-03-23 19:51:11 +00:00
parent f771a79dd9
commit d3c97ea09d

View file

@ -1,4 +1,4 @@
/* $Id: cnotify.c,v 1.4 2003/01/15 21:24:33 chorns Exp $ /* $Id: cnotify.c,v 1.5 2003/03/23 19:51:11 gdalsnes Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -11,11 +11,14 @@
#include <k32.h> #include <k32.h>
#define NDEBUG
#include <kernel32/kernel32.h>
WINBOOL STDCALL WINBOOL STDCALL
FindCloseChangeNotification (HANDLE hChangeHandle) FindCloseChangeNotification (HANDLE hChangeHandle)
{ {
return FALSE; NtClose(hChangeHandle);
return TRUE;
} }
@ -27,34 +30,34 @@ FindFirstChangeNotificationA (
DWORD dwNotifyFilter DWORD dwNotifyFilter
) )
{ {
#if 0
UNICODE_STRING PathNameU; UNICODE_STRING PathNameU;
ANSI_STRING PathName; ANSI_STRING PathName;
HANDLE Result; HANDLE hNotify;
RtlInitAnsiString (&PathName, RtlInitAnsiString (&PathName,
(LPSTR)lpPathName); (LPSTR)lpPathName);
/* convert ansi (or oem) string to unicode */ /* convert ansi (or oem) string to unicode */
if (bIsFileApiAnsi) if (bIsFileApiAnsi)
{
RtlAnsiStringToUnicodeString (&PathNameU, RtlAnsiStringToUnicodeString (&PathNameU,
&PathName, &PathName,
TRUE); TRUE);
}
else else
{
RtlOemStringToUnicodeString (&PathNameU, RtlOemStringToUnicodeString (&PathNameU,
&PathName, &PathName,
TRUE); TRUE);
}
Result = FindFirstChangeNotificationW (PathNameU.Buffer, hNotify = FindFirstChangeNotificationW (PathNameU.Buffer,
bWatchSubtree, bWatchSubtree,
dwNotifyFilter); dwNotifyFilter);
RtlFreeHeap (RtlGetProcessHeap (), RtlFreeUnicodeString(&PathNameU);
0,
RootPathNameU.Buffer);
return Result; return hNotify;
#endif
} }
@ -66,7 +69,63 @@ FindFirstChangeNotificationW (
DWORD dwNotifyFilter DWORD dwNotifyFilter
) )
{ {
return NULL; NTSTATUS Status;
UNICODE_STRING NtPathU;
IO_STATUS_BLOCK IoStatus;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE hDir;
/*
RtlDosPathNameToNtPathName takes a fully qualified file name "C:\Projects\LoadLibrary\Debug\TestDll.dll"
and returns something like "\??\C:\Projects\LoadLibrary\Debug\TestDll.dll."
If the file name cannot be interpreted, then the routine returns STATUS_OBJECT_PATH_SYNTAX_BAD and
ends execution.
*/
if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpPathName,
&NtPathU,
NULL,
NULL))
{
SetLastErrorByStatus(STATUS_PATH_SYNTAX_BAD);
return INVALID_HANDLE_VALUE;
}
InitializeObjectAttributes (&ObjectAttributes,
&NtPathU,
0,
NULL,
NULL);
Status = NtOpenFile (hDir,
SYNCHRONIZE|FILE_LIST_DIRECTORY,
&ObjectAttributes,
&IoStatus,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_DIRECTORY_FILE);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return INVALID_HANDLE_VALUE;
}
Status = NtNotifyChangeDirectoryFile(hDir,
NULL,
NULL,
NULL,
&IoStatus,
NULL,//Buffer,
0,//BufferLength,
dwNotifyFilter,
bWatchSubtree);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return INVALID_HANDLE_VALUE;
}
return hDir;
} }
@ -76,7 +135,26 @@ FindNextChangeNotification (
HANDLE hChangeHandle HANDLE hChangeHandle
) )
{ {
return FALSE; IO_STATUS_BLOCK IoStatus;
NTSTATUS Status;
Status = NtNotifyChangeDirectoryFile(hChangeHandle,
NULL,
NULL,
NULL,
&IoStatus,
NULL,//Buffer,
0,//BufferLength,
FILE_NOTIFY_CHANGE_SECURITY,//meaningless for subsequent calls, but must contain a valid flag(s)
0//meaningless for subsequent calls
);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return FALSE;
}
return TRUE;
} }
/* EOF */ /* EOF */