Release 990226.
[wine/gsoc-2012-control.git] / files / change.c
blobd5fce0649201776ad995c1b1e388fe3c977214e5
1 /*
2 * Win32 file change notification functions
4 * Copyright 1998 Ulrich Weigand
5 */
7 #include <assert.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <string.h>
11 #include <time.h>
12 #include "winbase.h"
13 #include "winerror.h"
14 #include "process.h"
15 #include "thread.h"
16 #include "heap.h"
17 #include "server.h"
18 #include "debug.h"
20 /* The change notification object */
21 typedef struct
23 K32OBJ header;
24 } CHANGE_OBJECT;
27 /****************************************************************************
28 * FindFirstChangeNotification32A (KERNEL32.248)
30 HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName,
31 BOOL bWatchSubtree,
32 DWORD dwNotifyFilter )
34 CHANGE_OBJECT *change;
35 struct create_change_notification_request req;
36 struct create_change_notification_reply reply;
38 req.subtree = bWatchSubtree;
39 req.filter = dwNotifyFilter;
40 CLIENT_SendRequest( REQ_CREATE_CHANGE_NOTIFICATION, -1, 1, &req, sizeof(req) );
41 CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL );
42 if (reply.handle == -1) return INVALID_HANDLE_VALUE;
44 change = HeapAlloc( SystemHeap, 0, sizeof(CHANGE_OBJECT) );
45 if (!change)
47 CLIENT_CloseHandle( reply.handle );
48 return INVALID_HANDLE_VALUE;
50 change->header.type = K32OBJ_CHANGE;
51 change->header.refcount = 1;
52 return HANDLE_Alloc( PROCESS_Current(), &change->header,
53 STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE /*FIXME*/,
54 FALSE, reply.handle );
57 /****************************************************************************
58 * FindFirstChangeNotification32W (KERNEL32.249)
60 HANDLE WINAPI FindFirstChangeNotificationW( LPCWSTR lpPathName,
61 BOOL bWatchSubtree,
62 DWORD dwNotifyFilter)
64 LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpPathName );
65 HANDLE ret = FindFirstChangeNotificationA( nameA, bWatchSubtree,
66 dwNotifyFilter );
67 if (nameA) HeapFree( GetProcessHeap(), 0, nameA );
68 return ret;
71 /****************************************************************************
72 * FindNextChangeNotification (KERNEL32.252)
74 BOOL WINAPI FindNextChangeNotification( HANDLE handle )
76 if (HANDLE_GetServerHandle( PROCESS_Current(), handle,
77 K32OBJ_FILE, 0 ) == -1)
78 return FALSE;
79 /* FIXME: do something */
80 return TRUE;
83 /****************************************************************************
84 * FindCloseChangeNotification (KERNEL32.247)
86 BOOL WINAPI FindCloseChangeNotification( HANDLE handle)
88 return CloseHandle( handle );