2 * filewatcher.c: File System Watcher internal calls
5 * Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 * (C) 2004 Novell, Inc. (http://www.novell.com)
14 #include <mono/metadata/appdomain.h>
15 #include <mono/metadata/exception.h>
16 #include <mono/metadata/filewatcher.h>
18 #if (defined (PLATFORM_WIN32) && WINVER >= 0x0400)
20 * We use the managed watcher on windows, so the code inside this #if is never used
23 ves_icall_System_IO_FSW_SupportsFSW (void)
29 ves_icall_System_IO_FSW_OpenDirectory (MonoString *path, gpointer reserved)
38 dir = CreateFile (path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE,
39 NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
46 ves_icall_System_IO_FSW_CloseDirectory (gpointer handle)
52 return CloseHandle (handle);
57 ves_icall_System_IO_FSW_ReadDirectoryChanges ( gpointer handle,
59 gboolean includeSubdirs,
68 MonoObject *delegate = (MonoObject *) callback;
70 LPOVERLAPPED_COMPLETION_ROUTINE func;
74 size = mono_array_length (buffer);
75 dest = mono_array_addr_with_size (buffer, 1, 0);
77 im = mono_get_delegate_invoke (mono_object_get_class (delegate));
78 func = mono_compile_method (im);
80 * return ReadDirectoryChanges (handle, dest, size, includeSubdirs, filters,
81 NULL, (LPOVERLAPPED) overlap,
86 ves_icall_System_IO_FAMW_InternalFAMNextEvent (gpointer conn,
87 MonoString **filename,
95 static int (*FAMNextEvent) (gpointer, gpointer);
98 ves_icall_System_IO_FSW_SupportsFSW (void)
108 filename = g_module_build_path (NULL, "libfam.so.0");
109 fam_module = g_module_open (filename, G_MODULE_BIND_LAZY);
111 if (fam_module == NULL)
114 g_module_symbol (fam_module, "FAMNextEvent", (gpointer *) &FAMNextEvent);
115 if (FAMNextEvent == NULL)
123 ves_icall_System_IO_FSW_OpenDirectory (MonoString *path, gpointer reserved)
129 ves_icall_System_IO_FSW_CloseDirectory (gpointer handle)
135 ves_icall_System_IO_FSW_ReadDirectoryChanges ( gpointer handle,
137 gboolean includeSubdirs,
145 /* Almost copied from fam.h. Weird, I know */
150 typedef struct FAMEvent {
154 gchar filename [PATH_MAX];
160 ves_icall_System_IO_FAMW_InternalFAMNextEvent (gpointer conn,
161 MonoString **filename,
169 if (FAMNextEvent (conn, &ev) == 1) {
170 *filename = mono_string_new (mono_domain_get (), ev.filename);
172 *reqnum = ev.fr.reqnum;