mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 22:52:09 +01:00
Add GError to file monitor calls
2008-01-14 Alexander Larsson <alexl@redhat.com> * gfile.[ch]: (g_file_monitor_directory): (g_file_monitor_file): Add GError to file monitor calls * glocaldirectorymonitor.c: * glocaldirectorymonitor.h: * glocalfile.c: * glocalfilemonitor.c: * glocalfilemonitor.h: * gunixmounts.c: Update for above change svn path=/trunk/; revision=6306
This commit is contained in:
parent
a80b1120f1
commit
3690cb75a6
@ -1,3 +1,18 @@
|
|||||||
|
2008-01-14 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* gfile.[ch]:
|
||||||
|
(g_file_monitor_directory):
|
||||||
|
(g_file_monitor_file):
|
||||||
|
Add GError to file monitor calls
|
||||||
|
|
||||||
|
* glocaldirectorymonitor.c:
|
||||||
|
* glocaldirectorymonitor.h:
|
||||||
|
* glocalfile.c:
|
||||||
|
* glocalfilemonitor.c:
|
||||||
|
* glocalfilemonitor.h:
|
||||||
|
* gunixmounts.c:
|
||||||
|
Update for above change
|
||||||
|
|
||||||
2008-01-14 Alexander Larsson <alexl@redhat.com>
|
2008-01-14 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
* glocalfile.c:
|
* glocalfile.c:
|
||||||
|
23
gio/gfile.c
23
gio/gfile.c
@ -3249,6 +3249,7 @@ g_file_eject_mountable_finish (GFile *file,
|
|||||||
* @file: input #GFile.
|
* @file: input #GFile.
|
||||||
* @flags: a set of #GFileMonitorFlags.
|
* @flags: a set of #GFileMonitorFlags.
|
||||||
* @cancellable: optional #GCancellable object, %NULL to ignore.
|
* @cancellable: optional #GCancellable object, %NULL to ignore.
|
||||||
|
* @error: a #GError, or %NULL.
|
||||||
*
|
*
|
||||||
* Obtains a directory monitor for the given file.
|
* Obtains a directory monitor for the given file.
|
||||||
* This may fail if directory monitoring is not supported.
|
* This may fail if directory monitoring is not supported.
|
||||||
@ -3263,18 +3264,27 @@ g_file_eject_mountable_finish (GFile *file,
|
|||||||
GFileMonitor*
|
GFileMonitor*
|
||||||
g_file_monitor_directory (GFile *file,
|
g_file_monitor_directory (GFile *file,
|
||||||
GFileMonitorFlags flags,
|
GFileMonitorFlags flags,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GFileIface *iface;
|
GFileIface *iface;
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
||||||
|
|
||||||
|
if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
iface = G_FILE_GET_IFACE (file);
|
iface = G_FILE_GET_IFACE (file);
|
||||||
|
|
||||||
if (iface->monitor_dir == NULL)
|
if (iface->monitor_dir == NULL)
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR,
|
||||||
|
G_IO_ERROR_NOT_SUPPORTED,
|
||||||
|
_("Operation not supported"));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return (* iface->monitor_dir) (file, flags, cancellable);
|
return (* iface->monitor_dir) (file, flags, cancellable, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3282,6 +3292,7 @@ g_file_monitor_directory (GFile *file,
|
|||||||
* @file: input #GFile.
|
* @file: input #GFile.
|
||||||
* @flags: a set of #GFileMonitorFlags.
|
* @flags: a set of #GFileMonitorFlags.
|
||||||
* @cancellable: optional #GCancellable object, %NULL to ignore.
|
* @cancellable: optional #GCancellable object, %NULL to ignore.
|
||||||
|
* @error: a #GError, or %NULL.
|
||||||
*
|
*
|
||||||
* Obtains a file monitor for the given file. If no file notification
|
* Obtains a file monitor for the given file. If no file notification
|
||||||
* mechanism exists, then regular polling of the file is used.
|
* mechanism exists, then regular polling of the file is used.
|
||||||
@ -3295,19 +3306,23 @@ g_file_monitor_directory (GFile *file,
|
|||||||
GFileMonitor*
|
GFileMonitor*
|
||||||
g_file_monitor_file (GFile *file,
|
g_file_monitor_file (GFile *file,
|
||||||
GFileMonitorFlags flags,
|
GFileMonitorFlags flags,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GFileIface *iface;
|
GFileIface *iface;
|
||||||
GFileMonitor *monitor;
|
GFileMonitor *monitor;
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
||||||
|
|
||||||
|
if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
iface = G_FILE_GET_IFACE (file);
|
iface = G_FILE_GET_IFACE (file);
|
||||||
|
|
||||||
monitor = NULL;
|
monitor = NULL;
|
||||||
|
|
||||||
if (iface->monitor_file)
|
if (iface->monitor_file)
|
||||||
monitor = (* iface->monitor_file) (file, flags, cancellable);
|
monitor = (* iface->monitor_file) (file, flags, cancellable, error);
|
||||||
|
|
||||||
/* Fallback to polling */
|
/* Fallback to polling */
|
||||||
if (monitor == NULL)
|
if (monitor == NULL)
|
||||||
|
12
gio/gfile.h
12
gio/gfile.h
@ -518,11 +518,13 @@ struct _GFileIface
|
|||||||
|
|
||||||
GFileMonitor* (*monitor_dir) (GFile *file,
|
GFileMonitor* (*monitor_dir) (GFile *file,
|
||||||
GFileMonitorFlags flags,
|
GFileMonitorFlags flags,
|
||||||
GCancellable *cancellable);
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
GFileMonitor* (*monitor_file) (GFile *file,
|
GFileMonitor* (*monitor_file) (GFile *file,
|
||||||
GFileMonitorFlags flags,
|
GFileMonitorFlags flags,
|
||||||
GCancellable *cancellable);
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -794,10 +796,12 @@ gboolean g_file_copy_attributes (GFile
|
|||||||
|
|
||||||
GFileMonitor* g_file_monitor_directory (GFile *file,
|
GFileMonitor* g_file_monitor_directory (GFile *file,
|
||||||
GFileMonitorFlags flags,
|
GFileMonitorFlags flags,
|
||||||
GCancellable *cancellable);
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
GFileMonitor* g_file_monitor_file (GFile *file,
|
GFileMonitor* g_file_monitor_file (GFile *file,
|
||||||
GFileMonitorFlags flags,
|
GFileMonitorFlags flags,
|
||||||
GCancellable *cancellable);
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
/* Utilities */
|
/* Utilities */
|
||||||
|
@ -276,8 +276,9 @@ get_default_local_directory_monitor (gpointer data)
|
|||||||
* Returns: new #GFileMonitor for the given @dirname.
|
* Returns: new #GFileMonitor for the given @dirname.
|
||||||
**/
|
**/
|
||||||
GFileMonitor*
|
GFileMonitor*
|
||||||
_g_local_directory_monitor_new (const char* dirname,
|
_g_local_directory_monitor_new (const char *dirname,
|
||||||
GFileMonitorFlags flags)
|
GFileMonitorFlags flags,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
static GOnce once_init = G_ONCE_INIT;
|
static GOnce once_init = G_ONCE_INIT;
|
||||||
GTypeClass *type_class;
|
GTypeClass *type_class;
|
||||||
@ -291,6 +292,8 @@ _g_local_directory_monitor_new (const char* dirname,
|
|||||||
monitor = NULL;
|
monitor = NULL;
|
||||||
if (type != G_TYPE_INVALID)
|
if (type != G_TYPE_INVALID)
|
||||||
monitor = G_FILE_MONITOR (g_object_new (type, "dirname", dirname, NULL));
|
monitor = G_FILE_MONITOR (g_object_new (type, "dirname", dirname, NULL));
|
||||||
|
else
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Unable to find default local directory monitor type"));
|
||||||
|
|
||||||
/* This is non-null on first pass here. Unref the class now.
|
/* This is non-null on first pass here. Unref the class now.
|
||||||
* This is to avoid unloading the module and then loading it
|
* This is to avoid unloading the module and then loading it
|
||||||
|
@ -59,7 +59,8 @@ struct _GLocalDirectoryMonitorClass {
|
|||||||
GType g_local_directory_monitor_get_type (void) G_GNUC_CONST;
|
GType g_local_directory_monitor_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GFileMonitor* _g_local_directory_monitor_new (const char* dirname,
|
GFileMonitor* _g_local_directory_monitor_new (const char* dirname,
|
||||||
GFileMonitorFlags flags);
|
GFileMonitorFlags flags,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -1861,19 +1861,21 @@ g_local_file_move (GFile *source,
|
|||||||
static GFileMonitor*
|
static GFileMonitor*
|
||||||
g_local_file_monitor_dir (GFile *file,
|
g_local_file_monitor_dir (GFile *file,
|
||||||
GFileMonitorFlags flags,
|
GFileMonitorFlags flags,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GLocalFile* local_file = G_LOCAL_FILE(file);
|
GLocalFile* local_file = G_LOCAL_FILE(file);
|
||||||
return _g_local_directory_monitor_new (local_file->filename, flags);
|
return _g_local_directory_monitor_new (local_file->filename, flags, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GFileMonitor*
|
static GFileMonitor*
|
||||||
g_local_file_monitor_file (GFile *file,
|
g_local_file_monitor_file (GFile *file,
|
||||||
GFileMonitorFlags flags,
|
GFileMonitorFlags flags,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GLocalFile* local_file = G_LOCAL_FILE(file);
|
GLocalFile* local_file = G_LOCAL_FILE(file);
|
||||||
return _g_local_file_monitor_new (local_file->filename, flags);
|
return _g_local_file_monitor_new (local_file->filename, flags, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -206,7 +206,8 @@ get_default_local_file_monitor (gpointer data)
|
|||||||
**/
|
**/
|
||||||
GFileMonitor*
|
GFileMonitor*
|
||||||
_g_local_file_monitor_new (const char *pathname,
|
_g_local_file_monitor_new (const char *pathname,
|
||||||
GFileMonitorFlags flags)
|
GFileMonitorFlags flags,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
static GOnce once_init = G_ONCE_INIT;
|
static GOnce once_init = G_ONCE_INIT;
|
||||||
GTypeClass *type_class;
|
GTypeClass *type_class;
|
||||||
@ -220,6 +221,8 @@ _g_local_file_monitor_new (const char *pathname,
|
|||||||
monitor = NULL;
|
monitor = NULL;
|
||||||
if (type != G_TYPE_INVALID)
|
if (type != G_TYPE_INVALID)
|
||||||
monitor = G_FILE_MONITOR (g_object_new (type, "filename", pathname, NULL));
|
monitor = G_FILE_MONITOR (g_object_new (type, "filename", pathname, NULL));
|
||||||
|
else
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Unable to find default local file monitor type"));
|
||||||
|
|
||||||
/* This is non-null on first pass here. Unref the class now.
|
/* This is non-null on first pass here. Unref the class now.
|
||||||
* This is to avoid unloading the module and then loading it
|
* This is to avoid unloading the module and then loading it
|
||||||
|
@ -53,7 +53,8 @@ struct _GLocalFileMonitorClass {
|
|||||||
GType g_local_file_monitor_get_type (void) G_GNUC_CONST;
|
GType g_local_file_monitor_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GFileMonitor* _g_local_file_monitor_new (const char* pathname,
|
GFileMonitor* _g_local_file_monitor_new (const char* pathname,
|
||||||
GFileMonitorFlags flags);
|
GFileMonitorFlags flags,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -1191,7 +1191,7 @@ g_unix_mount_monitor_init (GUnixMountMonitor *monitor)
|
|||||||
if (get_fstab_file () != NULL)
|
if (get_fstab_file () != NULL)
|
||||||
{
|
{
|
||||||
file = g_file_new_for_path (get_fstab_file ());
|
file = g_file_new_for_path (get_fstab_file ());
|
||||||
monitor->fstab_monitor = g_file_monitor_file (file, 0, NULL);
|
monitor->fstab_monitor = g_file_monitor_file (file, 0, NULL, NULL);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
|
|
||||||
g_signal_connect (monitor->fstab_monitor, "changed", (GCallback)fstab_file_changed, monitor);
|
g_signal_connect (monitor->fstab_monitor, "changed", (GCallback)fstab_file_changed, monitor);
|
||||||
@ -1200,7 +1200,7 @@ g_unix_mount_monitor_init (GUnixMountMonitor *monitor)
|
|||||||
if (get_mtab_monitor_file () != NULL)
|
if (get_mtab_monitor_file () != NULL)
|
||||||
{
|
{
|
||||||
file = g_file_new_for_path (get_mtab_monitor_file ());
|
file = g_file_new_for_path (get_mtab_monitor_file ());
|
||||||
monitor->mtab_monitor = g_file_monitor_file (file, 0, NULL);
|
monitor->mtab_monitor = g_file_monitor_file (file, 0, NULL, NULL);
|
||||||
g_object_unref (file);
|
g_object_unref (file);
|
||||||
|
|
||||||
g_signal_connect (monitor->mtab_monitor, "changed", (GCallback)mtab_file_changed, monitor);
|
g_signal_connect (monitor->mtab_monitor, "changed", (GCallback)mtab_file_changed, monitor);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user