FileMonitor
Object Hierarchy:
Description:
Monitors a file or directory for changes.
To obtain a `GFileMonitor` for a file or directory, use [method@Gio.File.monitor], [method@Gio.File.monitor_file], or [ method@Gio.File.monitor_directory].
To get informed about changes to the file or directory you are monitoring, connect to the [signal@Gio.FileMonitor:GFileMonitor:changed
] signal. The signal will be emitted in the thread-default main context (see [method@GLib.MainContext.push_thread_default]) of the thread
that the monitor was created in (though if the global default main context is blocked, this may cause notifications to be blocked even if the
thread-default context is still running).
Example: File monitoring:
public static int main () {
try {
File file = File.new_for_path (Environment.get_home_dir ());
FileMonitor monitor = file.monitor (FileMonitorFlags.NONE, null);
print ("Monitoring: %s\n", file.get_path ());
monitor.changed.connect ((src, dest, event) => {
if (dest != null) {
print ("%s: %s, %s\n", event.to_string (), src.get_path (), dest.get_path ());
} else {
print ("%s: %s\n", event.to_string (), src.get_path ());
}
});
new MainLoop ().run ();
} catch (Error err) {
print ("Error: %s\n", err.message);
}
return 0;
}
valac --pkg gio-2.0 GLib.File.monitor.vala
Namespace: GLib
Package: gio-2.0
Content:
Properties:
Creation methods:
Methods:
Signals:
Inherited Members:
All known members inherited from class GLib.Object