]> git.datanom.net - lensdb.git/blobdiff - src/main.c
Fix collecting lens data
[lensdb.git] / src / main.c
index ca8161e785c6f6e4e085a213fde1e0d5040db34f..d5c1bc47f8149977386b71076bc220b5f58d995d 100644 (file)
 #endif
 #include <gtk/gtk.h>
 #include <glib.h>
+#include <glib/gstdio.h>
 #include <glib-object.h>
 #include <stdio.h>
 #include "sqlite-storage.h"
 #include "gui.h"
-
+#include "lib/scanner.h"
 
 gint main(gint argc, gchar** argv) {
-       gtk_init(&argc, &argv);
-       printf("test\n");
-       if (init_gui()) {
-               fprintf(stderr, "Failed initializing GUI\n");
-               return 1;
+       gint status = 0;
+
+       //gchar* path = g_path_get_dirname(argv[0]);
+       gchar* path = g_build_filename(g_get_user_config_dir(), PACKAGE, NULL); //g_strconcat(g_get_home_dir(), "/.local/share/", PACKAGE, NULL);
+       if (!g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+               if (g_mkdir(path, 0766)) {
+                       fprintf(stderr, "%s: Failed to create dir for database\n", path);
+                       return EXIT_FAILURE;
+               }
+       }
+       fprintf(stdout, "workdir: %s\n", path);
+       if ((status = init_storage(path)) > 0) {
+               fprintf(stderr, "%s: Failed to open DB\n", path);
+       } else {
+               gtk_init(&argc, &argv);
+               if (init_gui()) {
+                       gchar* err = g_strdup_printf("Failed initializing GUI\n");
+                       fprintf(stderr, err);
+                       show_err_msg(GTK_MESSAGE_ERROR, err);
+                       g_free(err);
+                       return EXIT_FAILURE;
+               }
        }
+       g_free(path);
+       close_storage();
        
-       return 0;
+       return status;
 }
This page took 0.184963 seconds and 5 git commands to generate.