forked from enlightenment/efl
code cleanup - don't repeat profile loading code if possible
This commit is contained in:
parent
1d958d1a29
commit
cb55731a90
|
@ -1197,7 +1197,7 @@ _profile_fetch_from_conf(void)
|
|||
{
|
||||
char buf[PATH_MAX], *p, *s;
|
||||
Eet_File *ef = NULL;
|
||||
int len = 0;
|
||||
int len = 0, i;
|
||||
|
||||
// if env var - use profile without question
|
||||
s = getenv("ELM_PROFILE");
|
||||
|
@ -1212,31 +1212,13 @@ _profile_fetch_from_conf(void)
|
|||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
// user profile
|
||||
if (i == 0)
|
||||
_elm_config_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
|
||||
ef = eet_open(buf, EET_FILE_MODE_READ);
|
||||
if (ef)
|
||||
{
|
||||
p = eet_read(ef, "config", &len);
|
||||
if (p)
|
||||
{
|
||||
_elm_profile = malloc(len + 1);
|
||||
if (_elm_profile)
|
||||
{
|
||||
memcpy(_elm_profile, p, len);
|
||||
_elm_profile[len] = 0;
|
||||
free(p);
|
||||
}
|
||||
else free(p);
|
||||
eet_close(ef);
|
||||
p = strchr(_elm_profile, '/');
|
||||
if (p) *p = 0;
|
||||
return;
|
||||
}
|
||||
eet_close(ef);
|
||||
}
|
||||
|
||||
// system profile
|
||||
else if (i == 1)
|
||||
_elm_data_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
|
||||
ef = eet_open(buf, EET_FILE_MODE_READ);
|
||||
if (ef)
|
||||
|
@ -1259,6 +1241,7 @@ _profile_fetch_from_conf(void)
|
|||
}
|
||||
eet_close(ef);
|
||||
}
|
||||
}
|
||||
|
||||
_elm_profile = strdup("default");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue