Created
March 25, 2022 01:51
-
-
Save mwleeds/466a3da3e04d0913d5e7fac2e07c9c4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <glib.h> | |
#include <gio/gio.h> | |
#include <stdio.h> | |
static void | |
changed_cb (GFileMonitor *m, | |
GFile *f, | |
GFile *f2, | |
GFileMonitorEvent event_type, | |
gpointer user_data) | |
{ | |
g_printerr ("an event!\n"); | |
} | |
int main (int argc, char **argv) { | |
const char *path = "/home/mwleeds/adirectorythatdoesnotexist"; | |
g_autoptr(GFile) f = g_file_new_for_path (path); | |
g_autoptr(GError) error = NULL; | |
GMainContext *c; | |
c = g_main_context_new (); | |
g_autoptr(GFileMonitor) m = g_file_monitor_directory (f, G_FILE_MONITOR_WATCH_MOVES, NULL, &error); | |
if (!m) { | |
printf ("%s", error->message); | |
return 1; | |
} | |
g_signal_connect (m, "changed", G_CALLBACK (changed_cb), NULL); | |
while (1) | |
{ | |
g_main_context_iteration (c, TRUE); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment