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)
100 filename
= g_module_build_path (NULL
, "libfam.so.0");
101 fam_module
= g_module_open (filename
, G_MODULE_BIND_LAZY
);
103 if (fam_module
== NULL
)
106 g_module_symbol (fam_module
, "FAMNextEvent", (gpointer
*) &FAMNextEvent
);
107 if (FAMNextEvent
== NULL
)
115 ves_icall_System_IO_FSW_OpenDirectory (MonoString
*path
, gpointer reserved
)
121 ves_icall_System_IO_FSW_CloseDirectory (gpointer handle
)
127 ves_icall_System_IO_FSW_ReadDirectoryChanges ( gpointer handle
,
129 gboolean includeSubdirs
,
137 /* Almost copied from fam.h. Weird, I know */
142 typedef struct FAMEvent
{
146 gchar filename
[PATH_MAX
];
152 ves_icall_System_IO_FAMW_InternalFAMNextEvent (gpointer conn
,
153 MonoString
**filename
,
161 if (FAMNextEvent (conn
, &ev
) == 1) {
162 *filename
= mono_string_new (mono_domain_get (), ev
.filename
);
164 *reqnum
= ev
.fr
.reqnum
;