1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
4 * Copyright (C) 2006-2007 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 * Author: Vlad Grecescu <b100dian@gmail.com>
20 * Author: Chun-wei Fan <fanc999@yahoo.com.tw>
26 #include "gwin32filemonitor.h"
27 #include "gwin32fsmonitorutils.h"
31 G_DEFINE_TYPE_WITH_CODE (GWin32FileMonitor, g_win32_file_monitor, G_TYPE_LOCAL_FILE_MONITOR,
32 g_io_extension_point_implement (G_LOCAL_FILE_MONITOR_EXTENSION_POINT_NAME,
33 g_define_type_id, "win32filemonitor", 20))
36 g_win32_file_monitor_start (GLocalFileMonitor *monitor,
38 const gchar *basename,
39 const gchar *filename,
40 GFileMonitorSource *source)
42 GWin32FileMonitor *win32_monitor = G_WIN32_FILE_MONITOR (monitor);
43 gboolean isfile = (filename == NULL && basename == NULL) ? FALSE : TRUE;
45 win32_monitor->priv->fms = source;
49 g_win32_fs_monitor_init (win32_monitor->priv, dirname, basename, TRUE);
51 g_win32_fs_monitor_init (win32_monitor->priv, NULL, filename, TRUE);
53 g_win32_fs_monitor_init (win32_monitor->priv, dirname, NULL, FALSE);
57 g_win32_file_monitor_is_supported (void)
63 g_win32_file_monitor_init (GWin32FileMonitor* monitor)
65 monitor->priv = g_win32_fs_monitor_create (TRUE);
67 monitor->priv->self = G_FILE_MONITOR (monitor);
71 g_win32_file_monitor_finalize (GObject *base)
73 GWin32FileMonitor *monitor;
74 monitor = G_WIN32_FILE_MONITOR (base);
76 g_win32_fs_monitor_finalize (monitor->priv);
78 if (G_OBJECT_CLASS (g_win32_file_monitor_parent_class)->finalize)
79 (*G_OBJECT_CLASS (g_win32_file_monitor_parent_class)->finalize) (base);
83 g_win32_file_monitor_cancel (GFileMonitor* monitor)
85 GWin32FileMonitor *file_monitor;
86 file_monitor = G_WIN32_FILE_MONITOR (monitor);
88 g_win32_fs_monitor_close_handle (file_monitor->priv);
94 g_win32_file_monitor_class_init (GWin32FileMonitorClass *klass)
96 GObjectClass* gobject_class = G_OBJECT_CLASS (klass);
97 GFileMonitorClass *file_monitor_class = G_FILE_MONITOR_CLASS (klass);
98 GLocalFileMonitorClass *local_file_monitor_class = G_LOCAL_FILE_MONITOR_CLASS (klass);
100 gobject_class->finalize = g_win32_file_monitor_finalize;
101 file_monitor_class->cancel = g_win32_file_monitor_cancel;
103 local_file_monitor_class->is_supported = g_win32_file_monitor_is_supported;
104 local_file_monitor_class->start = g_win32_file_monitor_start;