mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-09 10:44:04 +02:00
win32/gwin32directorymonitor.h Whitespace cleanup to match GLib style.
2008-08-03 Tor Lillqvist <tml@novell.com> * win32/gwin32directorymonitor.h * win32/gwin32directorymonitor.c: Whitespace cleanup to match GLib style. svn path=/trunk/; revision=7291
This commit is contained in:
committed by
Tor Lillqvist
parent
3bf84fb1cc
commit
506eed4ebd
@@ -1,3 +1,9 @@
|
||||
2008-08-03 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* win32/gwin32directorymonitor.h
|
||||
* win32/gwin32directorymonitor.c: Whitespace cleanup to match GLib
|
||||
style.
|
||||
|
||||
2008-08-03 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* win32/gwin32directorymonitor.c
|
||||
|
@@ -28,7 +28,9 @@
|
||||
#include "giomodule.h"
|
||||
#include <windows.h>
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GWin32DirectoryMonitor, g_win32_directory_monitor, G_TYPE_LOCAL_DIRECTORY_MONITOR,
|
||||
G_DEFINE_TYPE_WITH_CODE (GWin32DirectoryMonitor,
|
||||
g_win32_directory_monitor,
|
||||
G_TYPE_LOCAL_DIRECTORY_MONITOR,
|
||||
g_io_extension_point_implement (G_LOCAL_DIRECTORY_MONITOR_EXTENSION_POINT_NAME,
|
||||
g_define_type_id,
|
||||
"readdirectorychanges",
|
||||
@@ -40,19 +42,26 @@ struct _GWin32DirectoryMonitorPrivate {
|
||||
gchar *file_notify_buffer;
|
||||
DWORD buffer_filled_bytes;
|
||||
HANDLE hDirectory;
|
||||
/** needed in the APC where we only have this private struct */
|
||||
/* Needed in the APC where we only have this private struct */
|
||||
GFileMonitor *self;
|
||||
};
|
||||
|
||||
static void g_win32_directory_monitor_finalize (GObject *base);
|
||||
static gboolean g_win32_directory_monitor_cancel (GFileMonitor *base);
|
||||
static GObject * g_win32_directory_monitor_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
|
||||
|
||||
static gboolean g_win32_directory_monitor_is_supported(void) {
|
||||
static GObject *g_win32_directory_monitor_constructor (GType type,
|
||||
guint n_construct_properties,
|
||||
GObjectConstructParam *construct_properties);
|
||||
|
||||
static gboolean
|
||||
g_win32_directory_monitor_is_supported (void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void g_win32_directory_monitor_finalize (GObject* base) {
|
||||
static void
|
||||
g_win32_directory_monitor_finalize (GObject *base)
|
||||
{
|
||||
GWin32DirectoryMonitor *self;
|
||||
self = G_WIN32_DIRECTORY_MONITOR (base);
|
||||
|
||||
@@ -63,12 +72,13 @@ static void g_win32_directory_monitor_finalize (GObject* base) {
|
||||
(*G_OBJECT_CLASS (g_win32_directory_monitor_parent_class)->finalize) (base);
|
||||
}
|
||||
|
||||
|
||||
static gboolean g_win32_directory_monitor_cancel (GFileMonitor* base) {
|
||||
static gboolean
|
||||
g_win32_directory_monitor_cancel (GFileMonitor *base)
|
||||
{
|
||||
GWin32DirectoryMonitor *self;
|
||||
self = G_WIN32_DIRECTORY_MONITOR (base);
|
||||
|
||||
/* this triggers a last callback() with nBytes=0 */
|
||||
/* This triggers a last callback() with nBytes=0 */
|
||||
if (self->priv->hDirectory != INVALID_HANDLE_VALUE)
|
||||
CloseHandle (self->priv->hDirectory);
|
||||
|
||||
@@ -77,7 +87,10 @@ static gboolean g_win32_directory_monitor_cancel (GFileMonitor* base) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CALLBACK g_win32_directory_monitor_callback (DWORD error, DWORD nBytes, LPOVERLAPPED lpOverlapped)
|
||||
static void CALLBACK
|
||||
g_win32_directory_monitor_callback (DWORD error,
|
||||
DWORD nBytes,
|
||||
LPOVERLAPPED lpOverlapped)
|
||||
{
|
||||
gulong offset;
|
||||
PFILE_NOTIFY_INFORMATION pfile_notify_walker;
|
||||
@@ -86,7 +99,9 @@ void CALLBACK g_win32_directory_monitor_callback (DWORD error, DWORD nBytes, LPO
|
||||
GFile *file;
|
||||
GWin32DirectoryMonitorPrivate *priv = (GWin32DirectoryMonitorPrivate *) lpOverlapped;
|
||||
|
||||
static GFileMonitorEvent events[] = {0,
|
||||
static GFileMonitorEvent events[] =
|
||||
{
|
||||
0,
|
||||
G_FILE_MONITOR_EVENT_CREATED, /* FILE_ACTION_ADDED */
|
||||
G_FILE_MONITOR_EVENT_DELETED, /* FILE_ACTION_REMOVED */
|
||||
G_FILE_MONITOR_EVENT_CHANGED, /* FILE_ACTION_MODIFIED */
|
||||
@@ -94,7 +109,7 @@ void CALLBACK g_win32_directory_monitor_callback (DWORD error, DWORD nBytes, LPO
|
||||
G_FILE_MONITOR_EVENT_CREATED, /* FILE_ACTION_RENAMED_NEW_NAME */
|
||||
};
|
||||
|
||||
if (!nBytes) /* monitor was cancelled/finalized */
|
||||
if (!nBytes) /* Monitor was cancelled/finalized */
|
||||
return;
|
||||
|
||||
if (g_file_monitor_is_cancelled (G_FILE_MONITOR (priv->self)))
|
||||
@@ -111,12 +126,23 @@ void CALLBACK g_win32_directory_monitor_callback (DWORD error, DWORD nBytes, LPO
|
||||
g_free (file_name);
|
||||
} while (pfile_notify_walker->NextEntryOffset);
|
||||
|
||||
ReadDirectoryChangesW (priv->hDirectory, (gpointer)priv->file_notify_buffer, priv->buffer_allocated_bytes, FALSE,
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
||||
FILE_NOTIFY_CHANGE_SIZE, &priv->buffer_filled_bytes, &priv->overlapped, g_win32_directory_monitor_callback);
|
||||
ReadDirectoryChangesW (priv->hDirectory,
|
||||
(gpointer)priv->file_notify_buffer,
|
||||
priv->buffer_allocated_bytes,
|
||||
FALSE,
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME |
|
||||
FILE_NOTIFY_CHANGE_DIR_NAME |
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
||||
FILE_NOTIFY_CHANGE_SIZE,
|
||||
&priv->buffer_filled_bytes,
|
||||
&priv->overlapped,
|
||||
g_win32_directory_monitor_callback);
|
||||
}
|
||||
|
||||
static GObject * g_win32_directory_monitor_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
|
||||
static GObject *
|
||||
g_win32_directory_monitor_constructor (GType type,
|
||||
guint n_construct_properties,
|
||||
GObjectConstructParam *construct_properties) {
|
||||
GObject *obj;
|
||||
GWin32DirectoryMonitorClass *klass;
|
||||
GObjectClass *parent_class;
|
||||
@@ -130,8 +156,14 @@ static GObject * g_win32_directory_monitor_constructor (GType type, guint n_cons
|
||||
self = G_WIN32_DIRECTORY_MONITOR (obj);
|
||||
wdirname = g_utf8_to_utf16 (G_LOCAL_DIRECTORY_MONITOR (obj)->dirname, -1, NULL, NULL, NULL);
|
||||
|
||||
self->priv->hDirectory = CreateFileW (wdirname, FILE_LIST_DIRECTORY, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL);
|
||||
self->priv->hDirectory = CreateFileW (wdirname,
|
||||
FILE_LIST_DIRECTORY,
|
||||
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
g_free (wdirname);
|
||||
if (self->priv->hDirectory == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -139,16 +171,25 @@ static GObject * g_win32_directory_monitor_constructor (GType type, guint n_cons
|
||||
return obj;
|
||||
}
|
||||
|
||||
result = ReadDirectoryChangesW (self->priv->hDirectory, (gpointer)self->priv->file_notify_buffer, self->priv->buffer_allocated_bytes, FALSE,
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
||||
FILE_NOTIFY_CHANGE_SIZE, &self->priv->buffer_filled_bytes, &self->priv->overlapped, g_win32_directory_monitor_callback);
|
||||
result = ReadDirectoryChangesW (self->priv->hDirectory,
|
||||
(gpointer)self->priv->file_notify_buffer,
|
||||
self->priv->buffer_allocated_bytes,
|
||||
FALSE,
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME |
|
||||
FILE_NOTIFY_CHANGE_DIR_NAME |
|
||||
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
||||
FILE_NOTIFY_CHANGE_SIZE,
|
||||
&self->priv->buffer_filled_bytes,
|
||||
&self->priv->overlapped,
|
||||
g_win32_directory_monitor_callback);
|
||||
/* Ignore errors */
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
static void g_win32_directory_monitor_class_init (GWin32DirectoryMonitorClass * klass) {
|
||||
|
||||
static void
|
||||
g_win32_directory_monitor_class_init (GWin32DirectoryMonitorClass *klass)
|
||||
{
|
||||
g_win32_directory_monitor_parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
G_OBJECT_CLASS (klass)->constructor = g_win32_directory_monitor_constructor;
|
||||
@@ -159,7 +200,8 @@ static void g_win32_directory_monitor_class_init (GWin32DirectoryMonitorClass *
|
||||
G_LOCAL_DIRECTORY_MONITOR_CLASS (klass)->is_supported = g_win32_directory_monitor_is_supported;
|
||||
}
|
||||
|
||||
static void g_win32_directory_monitor_init (GWin32DirectoryMonitor * self)
|
||||
static void
|
||||
g_win32_directory_monitor_init (GWin32DirectoryMonitor *self)
|
||||
{
|
||||
self->priv = (GWin32DirectoryMonitorPrivate*)g_new0 (GWin32DirectoryMonitorPrivate, 1);
|
||||
g_assert (self->priv != 0);
|
||||
|
Reference in New Issue
Block a user