[glib/wip/mount-watcher: 15/15] start on 'gio' tool



commit 52ed2d865765727478fea8be839ea3f9a5e25ccf
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Jan 14 16:38:51 2015 -0500

    start on 'gio' tool

 gio/gio.c |   62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/gio/gio.c b/gio/gio.c
new file mode 100644
index 0000000..83b94a0
--- /dev/null
+++ b/gio/gio.c
@@ -0,0 +1,62 @@
+#include <gio.h>
+
+
+
+static const GOptionEntry gio_watch_entries[] = {
+  { "dir", 'd', 0, G_OPTION_ARG_NONE, &gio_watch_dir,
+      "Force use of a directory monitor (default: depends on type)" },
+  { "file", 'f', 0, G_OPTION_ARG_NONE, &gio_watch_file,
+      "Force use of a file monitor (default: depends on type)" },
+  { "watch-hardlinks", 'h', 0, G_OPTION_ARG_NONE, &gio_watch_hardlinks,
+      "Monitor changes made via hard links (implies --file)" },
+  { "no-moves", 'n', 0, G_OPTION_ARG_NONE, &gio_watch_no_moves,
+      "Report moves and renames as simple deleted/created events" },
+  { NULL }
+};
+
+static int
+gio_watch (int     argc,
+           gchar **argv)
+{
+  GOptionContext *context;
+  GError **error = NULL;
+
+  context = g_option_context_new ("- monitor files and directories");
+  g_option_context_add_main_entries (context, &gio_watch_entries, NULL);
+  if (!g_option_context_parse (context, &argc, &argv, &error))
+    {
+      g_printerr ("option parsing failed: %s\n", error->message);
+      g_error_free (error);
+      return 1;
+    }
+
+  gio_watch_file |= gio_watch_hardlinks;
+
+  if (gio_watch_file && gio_watch_dir)
+    {
+      g_printerr ("can only specify one of --dir and --file (or --watch-hardlinks)");
+      return 1;
+    }
+
+  if (argv[1])
+
+}
+
+int
+main (int    argc,
+      char **argv)
+{
+  gchar *cmd;
+
+  if (argc < 2 || !g_str_equal (argv[1], "watch"))
+    {
+      g_printerr ("must say 'watch'\n");
+      return 1;
+
+    }
+
+  cmd = g_strconcat (argv[0], " ", argv[1]);
+  argv[1] = cmd;
+
+  gio_watch (argv + 2);
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]