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)
22 * We use the managed watcher on windows, so the code inside this #if is never used
25 ves_icall_System_IO_FSW_SupportsFSW (void)
31 ves_icall_System_IO_FSW_OpenDirectory (MonoString *path, gpointer reserved)
40 dir = CreateFile (path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE,
41 NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
48 ves_icall_System_IO_FSW_CloseDirectory (gpointer handle)
54 return CloseHandle (handle);
59 ves_icall_System_IO_FSW_ReadDirectoryChanges (gpointer handle,
61 gboolean includeSubdirs,
70 MonoObject *delegate = (MonoObject *) callback;
72 LPOVERLAPPED_COMPLETION_ROUTINE func;
76 size = mono_array_length (buffer);
77 dest = mono_array_addr_with_size (buffer, 1, 0);
79 im = mono_get_delegate_invoke (mono_object_get_class (delegate));
80 func = mono_compile_method (im);
82 * return ReadDirectoryChanges (handle, dest, size, includeSubdirs, filters,
83 NULL, (LPOVERLAPPED) overlap,
88 ves_icall_System_IO_FAMW_InternalFAMNextEvent (gpointer conn,
89 MonoString **filename,
97 static int (*FAMNextEvent) (gpointer, gpointer);
100 ves_icall_System_IO_FSW_SupportsFSW (void)
110 filename = g_module_build_path (NULL, "libfam.so.0");
111 fam_module = g_module_open (filename, G_MODULE_BIND_LAZY);
113 if (fam_module == NULL)
116 g_module_symbol (fam_module, "FAMNextEvent", (gpointer *) &FAMNextEvent);
117 if (FAMNextEvent == NULL)
125 ves_icall_System_IO_FSW_OpenDirectory (MonoString *path, gpointer reserved)
131 ves_icall_System_IO_FSW_CloseDirectory (gpointer handle)
137 ves_icall_System_IO_FSW_ReadDirectoryChanges (gpointer handle,
139 gboolean includeSubdirs,
147 /* Almost copied from fam.h. Weird, I know */
152 typedef struct FAMEvent {
156 gchar filename [PATH_MAX];
162 ves_icall_System_IO_FAMW_InternalFAMNextEvent (gpointer conn,
163 MonoString **filename,
171 if (FAMNextEvent (conn, &ev) == 1) {
172 *filename = mono_string_new (mono_domain_get (), ev.filename);
174 *reqnum = ev.fr.reqnum;