2 * Win32 file change notification functions
4 * Copyright 1998 Ulrich Weigand
21 static void CHANGE_Destroy( K32OBJ
*obj
);
23 const K32OBJ_OPS CHANGE_Ops
=
25 CHANGE_Destroy
/* destroy */
28 /* The change notification object */
38 /****************************************************************************
41 static void CHANGE_Destroy( K32OBJ
*obj
)
43 CHANGE_OBJECT
*change
= (CHANGE_OBJECT
*)obj
;
44 assert( obj
->type
== K32OBJ_CHANGE
);
46 if ( change
->lpPathName
)
48 HeapFree( SystemHeap
, 0, change
->lpPathName
);
49 change
->lpPathName
= NULL
;
52 obj
->type
= K32OBJ_UNKNOWN
;
53 HeapFree( SystemHeap
, 0, change
);
56 /****************************************************************************
57 * FindFirstChangeNotification32A (KERNEL32.248)
59 HANDLE32 WINAPI
FindFirstChangeNotification32A( LPCSTR lpPathName
,
61 DWORD dwNotifyFilter
)
63 CHANGE_OBJECT
*change
;
64 struct create_change_notification_request req
;
65 struct create_change_notification_reply reply
;
67 req
.subtree
= bWatchSubtree
;
68 req
.filter
= dwNotifyFilter
;
69 CLIENT_SendRequest( REQ_CREATE_CHANGE_NOTIFICATION
, -1, 1, &req
, sizeof(req
) );
70 CLIENT_WaitSimpleReply( &reply
, sizeof(reply
), NULL
);
71 if (reply
.handle
== -1) return INVALID_HANDLE_VALUE32
;
73 change
= HeapAlloc( SystemHeap
, 0, sizeof(CHANGE_OBJECT
) );
76 CLIENT_CloseHandle( reply
.handle
);
77 return INVALID_HANDLE_VALUE32
;
80 change
->header
.type
= K32OBJ_CHANGE
;
81 change
->header
.refcount
= 1;
83 change
->lpPathName
= HEAP_strdupA( SystemHeap
, 0, lpPathName
);
84 change
->bWatchSubtree
= bWatchSubtree
;
85 change
->dwNotifyFilter
= dwNotifyFilter
;
86 change
->notify
= FALSE
;
88 return HANDLE_Alloc( PROCESS_Current(), &change
->header
,
89 STANDARD_RIGHTS_REQUIRED
|SYNCHRONIZE
/*FIXME*/,
90 FALSE
, reply
.handle
);
93 /****************************************************************************
94 * FindFirstChangeNotification32W (KERNEL32.249)
96 HANDLE32 WINAPI
FindFirstChangeNotification32W( LPCWSTR lpPathName
,
100 LPSTR nameA
= HEAP_strdupWtoA( GetProcessHeap(), 0, lpPathName
);
101 HANDLE32 ret
= FindFirstChangeNotification32A( nameA
, bWatchSubtree
,
103 if (nameA
) HeapFree( GetProcessHeap(), 0, nameA
);
107 /****************************************************************************
108 * FindNextChangeNotification (KERNEL32.252)
110 BOOL32 WINAPI
FindNextChangeNotification( HANDLE32 handle
)
112 CHANGE_OBJECT
*change
;
115 if (!(change
= (CHANGE_OBJECT
*)HANDLE_GetObjPtr( PROCESS_Current(),
116 handle
, K32OBJ_CHANGE
,
117 0 /*FIXME*/, NULL
)) )
123 change
->notify
= FALSE
;
124 K32OBJ_DecCount( &change
->header
);
129 /****************************************************************************
130 * FindCloseChangeNotification (KERNEL32.247)
132 BOOL32 WINAPI
FindCloseChangeNotification( HANDLE32 handle
)
134 return CloseHandle( handle
);