config: make a config directory, if it is not. 59/45759/3
authorJaehwan Kim <jae.hwan.kim@samsung.com>
Wed, 17 Jun 2015 08:37:01 +0000 (17:37 +0900)
committerJaehwan Kim <jae.hwan.kim@samsung.com>
Tue, 11 Aug 2015 06:09:51 +0000 (23:09 -0700)
create the config directory to register flush file to eio_monitor.

Change-Id: I0d6fafceec561cc9e0d12ec3e2e4b1ebf0d89114
origin: upstream

src/lib/elm_config.c

index 08eb2a6393105e5f6ccb9cec3160707c0ec5f028..21b7dae302ec4fc94dfd990329281ef1c204d5d8 100644 (file)
@@ -3326,9 +3326,22 @@ _elm_config_sub_init(void)
      }
 #endif
    char buf[PATH_MAX];
+   size_t len;
+   int ok = 0;
 
-   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/flush",
-                          _elm_profile);
+   len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/");
+   if (len + 6 >= sizeof(buf)) // the space to add "/flush"
+     goto end;
+
+   ok = ecore_file_mkpath(buf);
+   if (!ok)
+     {
+        ERR("Problem accessing Elementary's user configuration directory: %s",
+            buf);
+        goto end;
+     }
+
+   strcat(buf, "flush");
    if (!ecore_file_exists(buf))
      {
         FILE *f = fopen(buf, "w+");
@@ -3337,11 +3350,13 @@ _elm_config_sub_init(void)
           {
              fprintf(f, "flush");
              fclose(f);
+             goto end;
           }
      }
    _eio_monitor = eio_monitor_add(buf);
    ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED, _elm_config_file_monitor_cb, NULL);
 
+end:
    _config_sub_apply();
 }