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)
19 /* Supported under windows */
21 ves_icall_System_IO_FSW_SupportsFSW (void)
27 ves_icall_System_IO_FSW_OpenDirectory (MonoString *path, gpointer reserved)
34 utf8path = mono_string_to_utf8 (path);
35 dir = CreateFile (path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE,
36 NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
43 ves_icall_System_IO_FSW_CloseDirectory (gpointer handle)
47 return CloseHandle (handle);
51 ves_icall_System_IO_FSW_ReadDirectoryChanges ( gpointer handle,
53 gboolean includeSubdirs,
60 MonoObject *delegate = (MonoObject *) callback;
62 LPOVERLAPPED_COMPLETION_ROUTINE func;
66 size = mono_array_length (buffer);
67 dest = mono_array_addr_with_size (buffer, 1, 0);
69 im = mono_get_delegate_invoke (mono_object_get_class (delegate));
70 func = mono_compile_method (im);
72 /* return ReadDirectoryChanges (handle, dest, size, includeSubdirs, filters,
73 NULL, (LPOVERLAPPED) overlap,
78 ves_icall_System_IO_FAMW_InternalFAMNextEvent (gpointer conn,
79 MonoString **filename,
87 static int (*FAMNextEvent) (gpointer, gpointer);
90 ves_icall_System_IO_FSW_SupportsFSW (void)
96 fam_module = g_module_open ("libfam", G_MODULE_BIND_LAZY);
97 if (fam_module == NULL) {
102 g_module_symbol (fam_module, "FAMNextEvent", (gpointer *) &FAMNextEvent);
103 if (FAMNextEvent == NULL)
110 ves_icall_System_IO_FSW_OpenDirectory (MonoString *path, gpointer reserved)
116 ves_icall_System_IO_FSW_CloseDirectory (gpointer handle)
122 ves_icall_System_IO_FSW_ReadDirectoryChanges ( gpointer handle,
124 gboolean includeSubdirs,
132 /* Almost copied from fam.h. Weird, I know */
137 typedef struct FAMEvent {
141 gchar filename [PATH_MAX];
147 ves_icall_System_IO_FAMW_InternalFAMNextEvent (gpointer conn,
148 MonoString **filename,
156 if (FAMNextEvent (conn, &ev) == 1) {
157 *filename = mono_string_new (mono_domain_get (), ev.filename);
159 *reqnum = ev.fr.reqnum;