elm config - add function to check if profile exists 93/83593/2
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Thu, 31 Dec 2015 07:37:25 +0000 (16:37 +0900)
committerThiep Ha <thiep.ha@samsung.com>
Fri, 12 Aug 2016 06:01:44 +0000 (23:01 -0700)
this adds a method to see if a profile exists.
elm_config_profile_exists().

@feature

Change-Id: I0bf4c7282495a8b92377a7929e0fd6c3cb8bd45f

src/lib/elm_config.c
src/lib/elm_config.h

index e78370b..7a5fe17 100644 (file)
@@ -2400,6 +2400,25 @@ elm_config_profile_list_free(Eina_List *l)
      eina_stringshare_del(dir);
 }
 
+EAPI Eina_Bool
+elm_config_profile_exists(const char *profile)
+{
+   char buf[PATH_MAX], buf2[PATH_MAX];
+
+   if (!profile) return EINA_FALSE;
+
+   _elm_config_user_dir_snprintf(buf, sizeof(buf),
+                                 "config/%s/base.cfg", profile);
+   if (ecore_file_exists(buf)) return EINA_TRUE;
+
+   snprintf(buf2, sizeof(buf2), "config/%s/base.cfg", profile);
+   eina_str_join_len(buf, sizeof(buf), '/',
+                     _elm_data_dir, strlen(_elm_data_dir),
+                     buf2, strlen(buf2));
+   if (ecore_file_exists(buf)) return EINA_TRUE;
+   return EINA_FALSE;
+}
+
 EAPI void
 elm_config_profile_set(const char *profile)
 {
index dbb800d..a6b0138 100644 (file)
@@ -141,6 +141,17 @@ EAPI Eina_List  *elm_config_profile_list_full_get(void);
 EAPI void        elm_config_profile_list_free(Eina_List *l);
 
 /**
+ * Return if a profile of the given name exists
+ * 
+ * @return EINA_TRUE if the profile exists, or EINA_FALSE if not
+ * @param profile The profile's name
+ * @ingroup Profile
+ *
+ * @since 1.17
+ */
+EAPI Eina_Bool   elm_config_profile_exists(const char *profile);
+
+/**
  * Set Elementary's profile.
  *
  * This sets the global profile that is applied to Elementary