#include <stdlib.h>
#include <pwd.h>
#include <string.h>
#include <sys/stat.h>
#include <gtk/gtk.h>
#include "gh-main-window.h"

char *
data_dir_path ()
{
  uid_t uid = getuid ();
  struct passwd *pw = getpwuid (uid);

  char *home_dir = pw->pw_dir;
  char *data_dir = "/.ghighlighter-c";

  int length = strlen (home_dir);
  length = length + strlen (data_dir);

  char *result = malloc (length + sizeof (char));
  strcat (result, home_dir);
  strcat (result, data_dir);

  return result;
}

void
setup_environment (char *data_dir)
{
  mkdir (data_dir, 0755);
}

int
main (int argc, char *argv[])
{
  char *data_dir = data_dir_path ();
  setup_environment (data_dir);
  free (data_dir);

  GtkWidget *window;

  gtk_init (&argc, &argv);

  window = gh_main_window_create ();
  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}

#include <stdlib.h>
#include <pwd.h>
#include <string.h>
#include <gtk/gtk.h>
#include "gh-main-window.h"

char *
data_dir_path ()
{
  uid_t uid = getuid ();
  struct passwd *pw = getpwuid (uid);

  char *home_dir = pw->pw_dir;
  char *data_dir = "/.ghighlighter-c";

  int length = strlen (home_dir);
  length = length + strlen (data_dir);

  char *result = malloc (length + sizeof (char));
  strcat (result, home_dir);
  strcat (result, data_dir);

  return result;
}

int
main (int argc, char *argv[])
{
  char *data_dir = data_dir_path ();
  free (data_dir);

  GtkWidget *window;

  gtk_init (&argc, &argv);

  window = gh_main_window_create ();
  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}

--- 
+++ 
@@ -1,6 +1,7 @@
 #include <stdlib.h>
 #include <pwd.h>
 #include <string.h>
+#include <sys/stat.h>
 #include <gtk/gtk.h>
 #include "gh-main-window.h"
 
@@ -23,10 +24,17 @@
   return result;
 }
 
+void
+setup_environment (char *data_dir)
+{
+  mkdir (data_dir, 0755);
+}
+
 int
 main (int argc, char *argv[])
 {
   char *data_dir = data_dir_path ();
+  setup_environment (data_dir);
   free (data_dir);
 
   GtkWidget *window;
Create data directory on startup
