major cleanup of path creation to $DATADIR and $HOME/.e/e

This cleanup replaces snprintf() usage with specific calls, they have
the benefit of being cleaner (so easier to grep), typing less and also
marginal speed up compared to the other (specially concat_static),
although those are rarely used in critical paths.

I'm testing it for some time and seems to not break anything, but let
me know of any problem. If you can review the patch and try to spot
incorrect names, please do.




SVN revision: 40014
This commit is contained in:
Gustavo Sverzut Barbieri 2009-04-13 14:56:38 +00:00
parent 64f80081aa
commit e0040cefb9
40 changed files with 663 additions and 503 deletions

View File

@ -43,7 +43,7 @@ e_about_new(E_Container *con)
FILE *f; FILE *f;
char buf[4096], buf2[4096], *tbuf; char buf[4096], buf2[4096], *tbuf;
snprintf(buf, sizeof(buf), "%s/AUTHORS", e_prefix_data_get()); e_prefix_data_concat_static(buf, "AUTHORS");
f = fopen(buf, "r"); f = fopen(buf, "r");
if (f) if (f)
{ {

View File

@ -60,18 +60,14 @@ e_config_init(void)
{ {
Eet_File *ef; Eet_File *ef;
char buf[4096]; char buf[4096];
const char *homedir;
/* try user profile config */ /* try user profile config */
homedir = e_user_homedir_get(); e_user_dir_concat_static(buf, "config/profile.cfg");
snprintf(buf, sizeof(buf), "%s/.e/e/config/profile.cfg",
homedir);
ef = eet_open(buf, EET_FILE_MODE_READ); ef = eet_open(buf, EET_FILE_MODE_READ);
if (!ef) if (!ef)
{ {
/* use system if no user profile config */ /* use system if no user profile config */
snprintf(buf, sizeof(buf), "%s/data/config/profile.cfg", e_prefix_data_concat_static(buf, "data/config/profile.cfg");
e_prefix_data_get());
ef = eet_open(buf, EET_FILE_MODE_READ); ef = eet_open(buf, EET_FILE_MODE_READ);
} }
if (ef) if (ef)
@ -99,8 +95,7 @@ e_config_init(void)
char *link = NULL; char *link = NULL;
/* check symlink - if default is a symlink to another dir */ /* check symlink - if default is a symlink to another dir */
snprintf(buf, sizeof(buf), "%s/data/config/default", e_prefix_data_concat_static(buf, "data/config/default");
e_prefix_data_get());
link = ecore_file_readlink(buf); link = ecore_file_readlink(buf);
/* if so use just the filename as the priofle - must be a local link */ /* if so use just the filename as the priofle - must be a local link */
if (link) if (link)
@ -1079,14 +1074,10 @@ EAPI char *
e_config_profile_dir_get(const char *prof) e_config_profile_dir_get(const char *prof)
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *homedir;
const char *dir;
homedir = e_user_homedir_get(); e_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof);
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s", homedir, prof);
if (ecore_file_is_dir(buf)) return strdup(buf); if (ecore_file_is_dir(buf)) return strdup(buf);
dir = e_prefix_data_get(); e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s", prof);
snprintf(buf, sizeof(buf), "%s/data/config/%s", dir, prof);
if (ecore_file_is_dir(buf)) return strdup(buf); if (ecore_file_is_dir(buf)) return strdup(buf);
return NULL; return NULL;
} }
@ -1101,19 +1092,20 @@ e_config_profile_list(void)
{ {
Eina_List *files; Eina_List *files;
char buf[PATH_MAX], *p; char buf[PATH_MAX], *p;
const char *homedir;
const char *dir;
Eina_List *flist = NULL; Eina_List *flist = NULL;
int len; size_t len;
homedir = e_user_homedir_get(); len = e_user_dir_concat_static(buf, "config");
len = snprintf(buf, sizeof(buf), "%s/.e/e/config/", homedir); if (len + 1 >= (int)sizeof(buf))
if (len >= (int)sizeof(buf))
return NULL; return NULL;
files = ecore_file_ls(buf);
buf[len] = '/';
len++;
p = buf + len; p = buf + len;
len = sizeof(buf) - len; len = sizeof(buf) - len;
files = ecore_file_ls(buf);
if (files) if (files)
{ {
char *file; char *file;
@ -1132,14 +1124,17 @@ e_config_profile_list(void)
free(file); free(file);
} }
} }
dir = e_prefix_data_get(); len = e_prefix_data_concat_static(buf, "data/config");
len = snprintf(buf, sizeof(buf), "%s/data/config/", dir); if (len >= sizeof(buf))
if (len >= (int)sizeof(buf))
return NULL; return NULL;
files = ecore_file_ls(buf);
buf[len] = '/';
len++;
p = buf + len; p = buf + len;
len = sizeof(buf) - len; len = sizeof(buf) - len;
files = ecore_file_ls(buf);
if (files) if (files)
{ {
char *file; char *file;
@ -1172,37 +1167,18 @@ EAPI void
e_config_profile_add(const char *prof) e_config_profile_add(const char *prof)
{ {
char buf[4096]; char buf[4096];
const char *homedir; if (e_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof) >= sizeof(buf))
return;
homedir = e_user_homedir_get();
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s", homedir, prof);
ecore_file_mkdir(buf); ecore_file_mkdir(buf);
} }
EAPI void EAPI void
e_config_profile_del(const char *prof) e_config_profile_del(const char *prof)
{ {
Eina_List *files;
char buf[4096]; char buf[4096];
const char *homedir; if (e_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof) >= sizeof(buf))
return;
homedir = e_user_homedir_get(); ecore_file_recursive_rm(buf);
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s", homedir, prof);
files = ecore_file_ls(buf);
if (files)
{
char *file;
EINA_LIST_FREE(files, file)
{
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/%s",
homedir, prof, file);
ecore_file_unlink(buf);
free(file);
}
}
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s", homedir, prof);
ecore_file_rmdir(buf);
} }
EAPI Eina_List * EAPI Eina_List *
@ -1243,12 +1219,10 @@ e_config_domain_load(const char *domain, E_Config_DD *edd)
{ {
Eet_File *ef; Eet_File *ef;
char buf[4096]; char buf[4096];
const char *homedir;
void *data = NULL; void *data = NULL;
homedir = e_user_homedir_get(); e_user_dir_snprintf(buf, sizeof(buf), "config/%s/%s.cfg",
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/%s.cfg", _e_config_profile, domain);
homedir, _e_config_profile, domain);
ef = eet_open(buf, EET_FILE_MODE_READ); ef = eet_open(buf, EET_FILE_MODE_READ);
if (ef) if (ef)
{ {
@ -1266,8 +1240,8 @@ e_config_domain_system_load(const char *domain, E_Config_DD *edd)
char buf[4096]; char buf[4096];
void *data = NULL; void *data = NULL;
snprintf(buf, sizeof(buf), "%s/data/config/%s/%s.cfg", e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s/%s.cfg",
e_prefix_data_get(), _e_config_profile, domain); _e_config_profile, domain);
ef = eet_open(buf, EET_FILE_MODE_READ); ef = eet_open(buf, EET_FILE_MODE_READ);
if (ef) if (ef)
{ {
@ -1284,13 +1258,11 @@ e_config_profile_save(void)
{ {
Eet_File *ef; Eet_File *ef;
char buf[4096], buf2[4096]; char buf[4096], buf2[4096];
const char *homedir;
int ok = 0; int ok = 0;
/* FIXME: check for other sessions fo E running */ /* FIXME: check for other sessions fo E running */
homedir = e_user_homedir_get(); e_user_dir_concat_static(buf, "config/profile.cfg");
snprintf(buf, sizeof(buf), "%s/.e/e/config/profile.cfg", homedir); e_user_dir_concat_static(buf2, "config/profile.cfg.tmp");
snprintf(buf2, sizeof(buf2), "%s.tmp", buf);
ef = eet_open(buf2, EET_FILE_MODE_WRITE); ef = eet_open(buf2, EET_FILE_MODE_WRITE);
if (ef) if (ef)
@ -1317,18 +1289,31 @@ e_config_domain_save(const char *domain, E_Config_DD *edd, const void *data)
{ {
Eet_File *ef; Eet_File *ef;
char buf[4096], buf2[4096]; char buf[4096], buf2[4096];
const char *homedir;
int ok = 0, ret; int ok = 0, ret;
size_t len, len2;
if (_e_config_save_block) return 0; if (_e_config_save_block) return 0;
/* FIXME: check for other sessions fo E running */ /* FIXME: check for other sessions fo E running */
homedir = e_user_homedir_get(); len = e_user_dir_snprintf(buf, sizeof(buf), "config/%s", _e_config_profile);
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s", if (len + 1 >= sizeof(buf)) return 0;
homedir, _e_config_profile);
ecore_file_mkdir(buf); ecore_file_mkdir(buf);
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/%s.cfg",
homedir, _e_config_profile, domain); buf[len] = '/';
snprintf(buf2, sizeof(buf2), "%s.tmp", buf); len++;
len2 = ecore_strlcpy(buf + len, domain, sizeof(buf) - len);
if (len2 + sizeof(".cfg") >= sizeof(buf) - len) return 0;
len += len2;
memcpy(buf + len, ".cfg", sizeof(".cfg"));
len += sizeof(".cfg") - 1;
if (len + sizeof(".tmp") >= sizeof(buf)) return 0;
memcpy(buf2, buf, len);
memcpy(buf2 + len, ".tmp", sizeof(".tmp"));
ef = eet_open(buf2, EET_FILE_MODE_WRITE); ef = eet_open(buf2, EET_FILE_MODE_WRITE);
if (ef) if (ef)
{ {

View File

@ -651,14 +651,12 @@ static Ecore_Event_Handler *_e_fm2_op_registry_entry_changed_handler = NULL;
EAPI int EAPI int
e_fm2_init(void) e_fm2_init(void)
{ {
const char *homedir;
char path[PATH_MAX]; char path[PATH_MAX];
eina_stringshare_init(); eina_stringshare_init();
ecore_job_init(); ecore_job_init();
_e_storage_volume_edd_init(); _e_storage_volume_edd_init();
homedir = e_user_homedir_get(); e_user_dir_concat_static(path, "fileman/metadata");
snprintf(path, sizeof(path), "%s/.e/e/fileman/metadata", homedir);
ecore_file_mkpath(path); ecore_file_mkpath(path);
_e_fm2_meta_path = strdup(path); _e_fm2_meta_path = strdup(path);
@ -3037,8 +3035,7 @@ _e_fm2_dev_path_map(const char *dev, const char *path)
.desktop files or symlinks (in fact anything .desktop files or symlinks (in fact anything
* you like * you like
*/ */
s = (char *)e_user_homedir_get(); if (e_user_dir_concat_static(buf, "fileman/favorites") >= sizeof(buf))
if (PRT("%s/.e/e/fileman/favorites", s) >= sizeof(buf))
return NULL; return NULL;
} }
else if (strcmp(dev, "desktop") == 0) else if (strcmp(dev, "desktop") == 0)
@ -3048,15 +3045,14 @@ _e_fm2_dev_path_map(const char *dev, const char *path)
.desktop files or symlinks (in fact anything .desktop files or symlinks (in fact anything
* you like * you like
*/ */
s = (char *)e_user_homedir_get();
if (strcmp(path, "/") == 0) if (strcmp(path, "/") == 0)
{ {
if (PRT("%s/Desktop", s) >= sizeof(buf)) if (e_user_homedir_concat_static(buf, "Desktop") >= sizeof(buf))
return NULL; return NULL;
} }
else else
{ {
if (PRT("%s/Desktop-%s", s, path) >= sizeof(buf)) if (e_user_homedir_snprintf(buf, sizeof(buf), "Desktop-%s", path) >= sizeof(buf))
return NULL; return NULL;
} }
ecore_file_mkpath(buf); ecore_file_mkpath(buf);

View File

@ -359,8 +359,7 @@ _e_fm2_custom_file_info_load(void)
if (_e_fm2_custom_file) return; if (_e_fm2_custom_file) return;
_e_fm2_custom_writes = 0; _e_fm2_custom_writes = 0;
snprintf(buf, sizeof(buf), "%s/.e/e/fileman/custom.cfg", e_user_dir_concat_static(buf, "fileman/custom.cfg");
e_user_homedir_get());
_e_fm2_custom_file = eet_open(buf, EET_FILE_MODE_READ); _e_fm2_custom_file = eet_open(buf, EET_FILE_MODE_READ);
if (!_e_fm2_custom_file) if (!_e_fm2_custom_file)
_e_fm2_custom_file = eet_open(buf, EET_FILE_MODE_WRITE); _e_fm2_custom_file = eet_open(buf, EET_FILE_MODE_WRITE);
@ -390,19 +389,22 @@ _e_fm2_custom_file_info_save(void)
{ {
Eet_File *ef; Eet_File *ef;
char buf[PATH_MAX], buf2[PATH_MAX]; char buf[PATH_MAX], buf2[PATH_MAX];
size_t len;
int ret; int ret;
if (!_e_fm2_custom_file) return; if (!_e_fm2_custom_file) return;
if (!_e_fm2_custom_writes) return; if (!_e_fm2_custom_writes) return;
snprintf(buf, sizeof(buf), "%s/.e/e/fileman/custom.cfg.tmp",
e_user_homedir_get()); len = e_user_dir_concat_static(buf, "fileman/custom.cfg.tmp");
if (len >= sizeof(buf)) return;
ef = eet_open(buf, EET_FILE_MODE_WRITE); ef = eet_open(buf, EET_FILE_MODE_WRITE);
if (!ef) return; if (!ef) return;
eina_hash_foreach(_e_fm2_custom_hash, eina_hash_foreach(_e_fm2_custom_hash,
_e_fm2_custom_file_hash_foreach_save, ef); _e_fm2_custom_file_hash_foreach_save, ef);
eet_close(ef); eet_close(ef);
snprintf(buf2, sizeof(buf2), "%s/.e/e/fileman/custom.cfg",
e_user_homedir_get()); memcpy(buf2, buf, len - sizeof(".tmp") - 1);
buf2[len - sizeof(".tmp") - 1] = '\0';
eet_close(_e_fm2_custom_file); eet_close(_e_fm2_custom_file);
_e_fm2_custom_file = NULL; _e_fm2_custom_file = NULL;
ret = rename(buf, buf2); ret = rename(buf, buf2);

View File

@ -286,8 +286,8 @@ _e_fm2_volume_write(E_Volume *v)
if (!v->storage) return; if (!v->storage) return;
id = ecore_file_file_get(v->storage->udi); id = ecore_file_file_get(v->storage->udi);
// printf("vol write %s\n", id); // printf("vol write %s\n", id);
snprintf(buf, sizeof(buf) - 1, "%s/.e/e/fileman/favorites/|%s_%d.desktop", e_user_dir_snprintf(buf, sizeof(buf), "fileman/favorites/|%s_%d.desktop",
e_user_homedir_get(), id, v->partition_number); id, v->partition_number);
f = fopen(buf, "w"); f = fopen(buf, "w");
if (f) if (f)
@ -313,8 +313,9 @@ _e_fm2_volume_write(E_Volume *v)
if (e_config->hal_desktop) if (e_config->hal_desktop)
{ {
snprintf(buf2, sizeof(buf2) - 1, "%s/Desktop/|%s_%d.desktop", e_user_homedir_snprintf(buf2, sizeof(buf2),
e_user_homedir_get(), id, v->partition_number); "Desktop/|%s_%d.desktop",
id, v->partition_number);
ecore_file_symlink(buf, buf2); ecore_file_symlink(buf, buf2);
} }
@ -337,15 +338,16 @@ _e_fm2_volume_erase(E_Volume *v)
if (!v->storage) return; if (!v->storage) return;
id = ecore_file_file_get(v->storage->udi); id = ecore_file_file_get(v->storage->udi);
snprintf(buf, sizeof(buf) - 1, "%s/Desktop/|%s_%d.desktop", e_user_homedir_snprintf(buf, sizeof(buf), "Desktop/|%s_%d.desktop",
e_user_homedir_get(), id, v->partition_number); id, v->partition_number);
ecore_file_unlink(buf); ecore_file_unlink(buf);
_e_fm2_file_force_update(buf); _e_fm2_file_force_update(buf);
if (e_config->hal_desktop) if (e_config->hal_desktop)
{ {
snprintf(buf, sizeof(buf) - 1, "%s/.e/e/fileman/favorites/|%s_%d.desktop", e_user_dir_snprintf(buf, sizeof(buf),
e_user_homedir_get(), id, v->partition_number); "fileman/favorites/|%s_%d.desktop",
id, v->partition_number);
ecore_file_unlink(buf); ecore_file_unlink(buf);
_e_fm2_file_force_update(buf); _e_fm2_file_force_update(buf);
} }
@ -530,11 +532,13 @@ e_fm2_hal_show_desktop_icons(void)
id = ecore_file_file_get(v->storage->udi); id = ecore_file_file_get(v->storage->udi);
snprintf(buf, sizeof(buf) - 1, "%s/.e/e/fileman/favorites/|%s_%d.desktop", e_user_dir_snprintf(buf, sizeof(buf),
e_user_homedir_get(), id, v->partition_number); "fileman/favorites/|%s_%d.desktop",
id, v->partition_number);
snprintf(buf2, sizeof(buf2) - 1, "%s/Desktop/|%s_%d.desktop", e_user_homedir_snprintf(buf2, sizeof(buf2),
e_user_homedir_get(), id, v->partition_number); "Desktop/|%s_%d.desktop",
id, v->partition_number);
if (ecore_file_exists(buf) && !ecore_file_exists(buf2)) if (ecore_file_exists(buf) && !ecore_file_exists(buf2))
{ {
@ -561,8 +565,9 @@ e_fm2_hal_hide_desktop_icons(void)
id = ecore_file_file_get(v->storage->udi); id = ecore_file_file_get(v->storage->udi);
snprintf(buf, sizeof(buf) - 1, "%s/Desktop/|%s_%d.desktop", e_user_homedir_snprintf(buf, sizeof(buf),
e_user_homedir_get(), id, v->partition_number); "Desktop/|%s_%d.desktop",
id, v->partition_number);
if (ecore_file_exists(buf)) if (ecore_file_exists(buf))
{ {

View File

@ -37,9 +37,9 @@ EAPI const char *
e_fm_mime_icon_get(const char *mime) e_fm_mime_icon_get(const char *mime)
{ {
char buf[4096], buf2[4096], *val; char buf[4096], buf2[4096], *val;
const char *homedir = NULL;
Eina_List *l = NULL; Eina_List *l = NULL;
E_Config_Mime_Icon *mi; E_Config_Mime_Icon *mi;
size_t len;
/* 0.0 clean out hash cache once it has mroe than 512 entries in it */ /* 0.0 clean out hash cache once it has mroe than 512 entries in it */
if (eina_hash_population(icon_map) > 512) e_fm_mime_icon_cache_flush(); if (eina_hash_population(icon_map) > 512) e_fm_mime_icon_cache_flush();
@ -64,41 +64,60 @@ e_fm_mime_icon_get(const char *mime)
} }
/* 2. look up in ~/.e/e/icons */ /* 2. look up in ~/.e/e/icons */
homedir = e_user_homedir_get(); len = e_user_dir_snprintf(buf, sizeof(buf), "icons/%s.edj", mime);
if (len >= sizeof(buf))
goto try_e_icon_generic;
snprintf(buf, sizeof(buf), "%s/.e/e/icons/%s.edj", homedir, mime);
if (ecore_file_exists(buf)) goto ok; if (ecore_file_exists(buf)) goto ok;
snprintf(buf, sizeof(buf), "%s/.e/e/icons/%s.svg", homedir, mime); memcpy(buf + len - sizeof("edj") - 1, "svg", sizeof("svg"));
if (ecore_file_exists(buf)) goto ok; if (ecore_file_exists(buf)) goto ok;
snprintf(buf, sizeof(buf), "%s/.e/e/icons/%s.png", homedir, mime); memcpy(buf + len - sizeof("edj") - 1, "png", sizeof("png"));
if (ecore_file_exists(buf)) goto ok; if (ecore_file_exists(buf)) goto ok;
snprintf(buf, sizeof(buf), "%s/.e/e/icons/%s.edj", homedir, buf2);
try_e_icon_generic:
len = e_user_dir_snprintf(buf, sizeof(buf), "icons/%s.edj", buf2);
if (len >= sizeof(buf))
goto try_theme;
if (ecore_file_exists(buf)) goto ok; if (ecore_file_exists(buf)) goto ok;
snprintf(buf, sizeof(buf), "%s/.e/e/icons/%s.svg", homedir, buf2); memcpy(buf + len - sizeof("edj") - 1, "svg", sizeof("svg"));
if (ecore_file_exists(buf)) goto ok; if (ecore_file_exists(buf)) goto ok;
snprintf(buf, sizeof(buf), "%s/.e/e/icons/%s.png", homedir, buf2); memcpy(buf + len - sizeof("edj") - 1, "png", sizeof("png"));
if (ecore_file_exists(buf)) goto ok; if (ecore_file_exists(buf)) goto ok;
/* 3. look up icon in theme */ /* 3. look up icon in theme */
snprintf(buf, sizeof(buf), "e/icons/fileman/mime/%s", mime); try_theme:
memcpy(buf, "e/icons/fileman/mime/", sizeof("e/icons/fileman/mime/") - 1);
ecore_strlcpy(buf + sizeof("e/icons/fileman/mime/") - 1, mime,
sizeof(buf) - sizeof("e/icons/fileman/mime/") - 1);
val = (char *)e_theme_edje_file_get("base/theme/fileman", buf); val = (char *)e_theme_edje_file_get("base/theme/fileman", buf);
if ((val) && (e_util_edje_collection_exists(val, buf))) goto ok; if ((val) && (e_util_edje_collection_exists(val, buf))) goto ok;
snprintf(buf, sizeof(buf), "e/icons/fileman/mime/%s", buf2);
ecore_strlcpy(buf + sizeof("e/icons/fileman/mime/") - 1, buf2,
sizeof(buf) - sizeof("e/icons/fileman/mime/") - 1);
val = (char *)e_theme_edje_file_get("base/theme/fileman", buf); val = (char *)e_theme_edje_file_get("base/theme/fileman", buf);
if ((val) && (e_util_edje_collection_exists(val, buf))) goto ok; if ((val) && (e_util_edje_collection_exists(val, buf))) goto ok;
/* 4. look up icon in PREFIX/share/enlightent/data/icons */ /* 4. look up icon in PREFIX/share/enlightent/data/icons */
snprintf(buf, sizeof(buf), "%s/data/icons/%s.edj", e_prefix_data_get(), mime); len = e_prefix_data_snprintf(buf, sizeof(buf), "data/icons/%s.edj", mime);
if (len >= sizeof(buf))
goto try_efreet_icon_generic;
if (ecore_file_exists(buf)) goto ok; if (ecore_file_exists(buf)) goto ok;
snprintf(buf, sizeof(buf), "%s/data/icons/%s.svg", e_prefix_data_get(), mime); memcpy(buf + len - sizeof("edj") - 1, "svg", sizeof("svg"));
if (ecore_file_exists(buf)) goto ok; if (ecore_file_exists(buf)) goto ok;
snprintf(buf, sizeof(buf), "%s/data/icons/%s.png", e_prefix_data_get(), mime); memcpy(buf + len - sizeof("edj") - 1, "png", sizeof("png"));
if (ecore_file_exists(buf)) goto ok; if (ecore_file_exists(buf)) goto ok;
snprintf(buf, sizeof(buf), "%s/data/icons/%s.edj", e_prefix_data_get(), buf2);
try_efreet_icon_generic:
len = e_prefix_data_snprintf(buf, sizeof(buf), "data/icons/%s.edj", buf2);
if (len >= sizeof(buf))
goto try_efreet_icon_generic;
if (ecore_file_exists(buf)) goto ok; if (ecore_file_exists(buf)) goto ok;
snprintf(buf, sizeof(buf), "%s/data/icons/%s.svg", e_prefix_data_get(), buf2); memcpy(buf + len - sizeof("edj") - 1, "svg", sizeof("svg"));
if (ecore_file_exists(buf)) goto ok; if (ecore_file_exists(buf)) goto ok;
snprintf(buf, sizeof(buf), "%s/data/icons/%s.png", e_prefix_data_get(), buf2); memcpy(buf + len - sizeof("edj") - 1, "png", sizeof("png"));
if (ecore_file_exists(buf)) goto ok; if (ecore_file_exists(buf)) goto ok;
return NULL; return NULL;

View File

@ -1065,8 +1065,7 @@ _e_border_menu_cb_fav_add(void *data, E_Menu *m, E_Menu_Item *mi)
char buf[4096]; char buf[4096];
if (!(bd = data)) return; if (!(bd = data)) return;
snprintf(buf, sizeof(buf), "%s/.e/e/applications/menu/favorite.menu", e_user_dir_concat_static(buf, "applications/menu/favorite.menu");
e_user_homedir_get());
menu = efreet_menu_parse(buf); menu = efreet_menu_parse(buf);
if (!menu) return; if (!menu) return;
efreet_menu_desktop_insert(menu, bd->desktop, -1); efreet_menu_desktop_insert(menu, bd->desktop, -1);
@ -1095,21 +1094,25 @@ _e_border_menu_cb_ibar_add_pre(void *data, E_Menu *m, E_Menu_Item *mi)
Eina_List *dirs; Eina_List *dirs;
Eina_List *l; Eina_List *l;
char buf[4096], *file; char buf[4096], *file;
const char *homedir; size_t len;
if (!(bd = data)) return; if (!(bd = data)) return;
homedir = e_user_homedir_get(); len = e_user_dir_concat_static(buf, "applications/bar");
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar", homedir); if (len + 1 >= sizeof(buf)) return;
dirs = ecore_file_ls(buf); dirs = ecore_file_ls(buf);
if (!dirs) return; if (!dirs) return;
buf[len] = '/';
len++;
sm = e_menu_new(); sm = e_menu_new();
EINA_LIST_FOREACH(dirs, l, file) EINA_LIST_FOREACH(dirs, l, file)
{ {
E_Menu_Item *smi; E_Menu_Item *smi;
if (file[0] == '.') continue; if (file[0] == '.') continue;
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s", homedir, file);
ecore_strlcpy(buf + len, file, sizeof(buf) - len);
if (ecore_file_is_dir(buf)) if (ecore_file_is_dir(buf))
{ {
smi = e_menu_item_new(sm); smi = e_menu_item_new(sm);
@ -1131,8 +1134,8 @@ _e_border_menu_cb_ibar_add(void *data, E_Menu *m, E_Menu_Item *mi)
bd = e_object_data_get(E_OBJECT(m)); bd = e_object_data_get(E_OBJECT(m));
if ((!bd) || (!bd->desktop)) return; if ((!bd) || (!bd->desktop)) return;
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s/.order", e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s/.order",
e_user_homedir_get(), (char *)data); (const char *)data);
od = e_order_new(buf); od = e_order_new(buf);
if (!od) return; if (!od) return;
e_order_append(od, bd->desktop); e_order_append(od, bd->desktop);

View File

@ -281,12 +281,8 @@ e_int_menus_favorite_apps_new(void)
{ {
E_Menu *m = NULL; E_Menu *m = NULL;
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *homedir;
homedir = e_user_homedir_get();
snprintf(buf, sizeof(buf),
"%s/.e/e/applications/menu/favorite.menu", homedir);
e_user_dir_concat_static(buf, "applications/menu/favorite.menu");
if (ecore_file_exists(buf)) m = e_int_menus_apps_new(buf); if (ecore_file_exists(buf)) m = e_int_menus_apps_new(buf);
return m; return m;
} }

View File

@ -397,7 +397,7 @@ e_intl_imc_personal_path_get(void)
{ {
char buf[4096]; char buf[4096];
snprintf(buf, sizeof(buf), "%s/.e/e/input_methods", e_user_homedir_get()); e_user_dir_concat_static(buf, "input_methods");
_e_intl_imc_personal_path = eina_stringshare_add(buf); _e_intl_imc_personal_path = eina_stringshare_add(buf);
} }
return _e_intl_imc_personal_path; return _e_intl_imc_personal_path;
@ -410,7 +410,7 @@ e_intl_imc_system_path_get(void)
{ {
char buf[4096]; char buf[4096];
snprintf(buf, sizeof(buf), "%s/data/input_methods", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/input_methods");
_e_intl_imc_system_path = eina_stringshare_add(buf); _e_intl_imc_system_path = eina_stringshare_add(buf);
} }
return _e_intl_imc_system_path; return _e_intl_imc_system_path;

View File

@ -217,9 +217,8 @@ main(int argc, char **argv)
{ {
/* do some extra tests to see if the prefix really is right */ /* do some extra tests to see if the prefix really is right */
char buf[4096]; char buf[4096];
snprintf(buf, sizeof(buf), "%s/data/themes/default.edj", e_prefix_data_concat_static(buf, "data/themes/default.edj");
e_prefix_data_get());
if (!ecore_file_exists(buf)) if (!ecore_file_exists(buf))
{ {
printf("WARNING: Prefix guess was wrong. Guessed:\n" printf("WARNING: Prefix guess was wrong. Guessed:\n"
@ -378,10 +377,7 @@ main(int argc, char **argv)
TS("arg parse done"); TS("arg parse done");
/* fixes for FOOLS that keep cp'ing default.edj into ~/.e/e/themes */ /* fixes for FOOLS that keep cp'ing default.edj into ~/.e/e/themes */
{ {
const char *homedir; e_user_dir_concat_static(buf, "themes/default.edj");
homedir = e_user_homedir_get();
snprintf(buf, sizeof(buf), "%s/.e/e/themes/default.edj", homedir);
if (ecore_file_exists(buf)) if (ecore_file_exists(buf))
ecore_file_unlink(buf); ecore_file_unlink(buf);
} }
@ -693,7 +689,7 @@ main(int argc, char **argv)
e_canvas_add(ee); e_canvas_add(ee);
im = evas_object_image_add(ecore_evas_get(ee)); im = evas_object_image_add(ecore_evas_get(ee));
snprintf(buf, sizeof(buf), "%s/data/images/test.png", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/images/test.png");
evas_object_image_file_set(im, buf, NULL); evas_object_image_file_set(im, buf, NULL);
if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE) if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
{ {
@ -702,7 +698,7 @@ main(int argc, char **argv)
_e_main_shutdown(-1); _e_main_shutdown(-1);
} }
snprintf(buf, sizeof(buf), "%s/data/images/test.jpg", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/images/test.jpg");
evas_object_image_file_set(im, buf, NULL); evas_object_image_file_set(im, buf, NULL);
if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE) if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
{ {
@ -711,7 +707,7 @@ main(int argc, char **argv)
_e_main_shutdown(-1); _e_main_shutdown(-1);
} }
snprintf(buf, sizeof(buf), "%s/data/images/test.edj", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/images/test.edj");
evas_object_image_file_set(im, buf, "images/0"); evas_object_image_file_set(im, buf, "images/0");
if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE) if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
{ {
@ -782,9 +778,9 @@ main(int argc, char **argv)
list = efreet_icon_extra_list_get(); list = efreet_icon_extra_list_get();
if (list) if (list)
{ {
snprintf(buf, sizeof(buf), "%s/.e/e/icons", e_user_homedir_get()); e_user_dir_concat_static(buf, "icons");
*list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf)); *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf));
snprintf(buf, sizeof(buf), "%s/data/icons", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/icons");
*list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf)); *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf));
} }
} }
@ -1169,8 +1165,7 @@ _e_main_x_shutdown(void)
static int static int
_e_main_dirs_init(void) _e_main_dirs_init(void)
{ {
const char *homedir; const char *base;
char buf[PATH_MAX];
const char *dirs[] = { const char *dirs[] = {
"images", "images",
"fonts", "fonts",
@ -1192,20 +1187,12 @@ _e_main_dirs_init(void)
"input_methods", "input_methods",
NULL NULL
}; };
int baselen;
homedir = e_user_homedir_get(); base = e_user_dir_get();
baselen = snprintf(buf, sizeof(buf), "%s/.e/e", homedir); if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs)/sizeof(dirs[0]) - 1)
if (baselen >= (int)sizeof(buf))
{
e_error_message_show("Error could not join:\n'%s'\nand\n'/.e/e",
homedir);
return 0;
}
if (ecore_file_mksubdirs(buf, dirs) != sizeof(dirs)/sizeof(dirs[0]) - 1)
{ {
e_error_message_show e_error_message_show
("Could not create one of the required subdirectories of '%s'", buf); ("Could not create one of the required subdirectories of '%s'", base);
return 0; return 0;
} }
@ -1334,7 +1321,7 @@ _e_main_path_init(void)
e_error_message_show("Cannot allocate path for path_data\n"); e_error_message_show("Cannot allocate path for path_data\n");
return 0; return 0;
} }
snprintf(buf, sizeof(buf), "%s/data", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data");
e_path_default_path_append(path_data, buf); e_path_default_path_append(path_data, buf);
e_path_user_path_set(path_data, &(e_config->path_append_data)); e_path_user_path_set(path_data, &(e_config->path_append_data));
@ -1346,7 +1333,7 @@ _e_main_path_init(void)
return 0; return 0;
} }
e_path_default_path_append(path_images, "~/.e/e/images"); e_path_default_path_append(path_images, "~/.e/e/images");
snprintf(buf, sizeof(buf), "%s/data/images", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/images");
e_path_default_path_append(path_images, buf); e_path_default_path_append(path_images, buf);
e_path_user_path_set(path_images, &(e_config->path_append_images)); e_path_user_path_set(path_images, &(e_config->path_append_images));
@ -1358,7 +1345,7 @@ _e_main_path_init(void)
return 0; return 0;
} }
e_path_default_path_append(path_fonts, "~/.e/e/fonts"); e_path_default_path_append(path_fonts, "~/.e/e/fonts");
snprintf(buf, sizeof(buf), "%s/data/fonts", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/fonts");
e_path_default_path_append(path_fonts, buf); e_path_default_path_append(path_fonts, buf);
e_path_user_path_set(path_fonts, &(e_config->path_append_fonts)); e_path_user_path_set(path_fonts, &(e_config->path_append_fonts));
@ -1370,7 +1357,7 @@ _e_main_path_init(void)
return 0; return 0;
} }
e_path_default_path_append(path_themes, "~/.e/e/themes"); e_path_default_path_append(path_themes, "~/.e/e/themes");
snprintf(buf, sizeof(buf), "%s/data/themes", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/themes");
e_path_default_path_append(path_themes, buf); e_path_default_path_append(path_themes, buf);
e_path_user_path_set(path_themes, &(e_config->path_append_themes)); e_path_user_path_set(path_themes, &(e_config->path_append_themes));
@ -1382,7 +1369,7 @@ _e_main_path_init(void)
return 0; return 0;
} }
e_path_default_path_append(path_icons, "~/.e/e/icons"); e_path_default_path_append(path_icons, "~/.e/e/icons");
snprintf(buf, sizeof(buf), "%s/data/icons", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/icons");
e_path_default_path_append(path_icons, buf); e_path_default_path_append(path_icons, buf);
e_path_user_path_set(path_icons, &(e_config->path_append_icons)); e_path_user_path_set(path_icons, &(e_config->path_append_icons));
@ -1412,7 +1399,7 @@ _e_main_path_init(void)
return 0; return 0;
} }
e_path_default_path_append(path_backgrounds, "~/.e/e/backgrounds"); e_path_default_path_append(path_backgrounds, "~/.e/e/backgrounds");
snprintf(buf, sizeof(buf), "%s/data/backgrounds", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/backgrounds");
e_path_default_path_append(path_backgrounds, buf); e_path_default_path_append(path_backgrounds, buf);
e_path_user_path_set(path_backgrounds, &(e_config->path_append_backgrounds)); e_path_user_path_set(path_backgrounds, &(e_config->path_append_backgrounds));

View File

@ -17,6 +17,8 @@ static char *_prefix_path_bin = NULL;
static char *_prefix_path_data = NULL; static char *_prefix_path_data = NULL;
static char *_prefix_path_lib = NULL; static char *_prefix_path_lib = NULL;
static size_t _prefix_path_data_len = 0;
#define PREFIX_CACHE_FILE 1 #define PREFIX_CACHE_FILE 1
#define SHARE_D "share/enlightenment" #define SHARE_D "share/enlightenment"
#define MAGIC_FILE "AUTHORS" #define MAGIC_FILE "AUTHORS"
@ -56,10 +58,13 @@ e_prefix_determine(char *argv0)
} }
if (getenv("E_DATA_DIR")) if (getenv("E_DATA_DIR"))
_prefix_path_data = strdup(getenv("E_DATA_DIR")); {
_prefix_path_data = strdup(getenv("E_DATA_DIR"));
_prefix_path_data_len = strlen(_prefix_path_data);
}
else else
{ {
snprintf(buf, sizeof(buf), "%s/"SHARE_D, _prefix_path); _prefix_path_data_len = snprintf(buf, sizeof(buf), "%s/"SHARE_D, _prefix_path);
_prefix_path_data = strdup(buf); _prefix_path_data = strdup(buf);
e_util_env_set("E_DATA_DIR", _prefix_path_data); e_util_env_set("E_DATA_DIR", _prefix_path_data);
} }
@ -122,7 +127,7 @@ e_prefix_determine(char *argv0)
snprintf(buf, sizeof(buf), "%s/"MAGIC_DAT, _prefix_path); snprintf(buf, sizeof(buf), "%s/"MAGIC_DAT, _prefix_path);
if (ecore_file_exists(buf)) if (ecore_file_exists(buf))
{ {
snprintf(buf, sizeof(buf), "%s/"SHARE_D, _prefix_path); _prefix_path_data_len = snprintf(buf, sizeof(buf), "%s/"SHARE_D, _prefix_path);
_prefix_path_data = strdup(buf); _prefix_path_data = strdup(buf);
snprintf(buf, sizeof(buf), "%s/"LOCALE_D, _prefix_path); snprintf(buf, sizeof(buf), "%s/"LOCALE_D, _prefix_path);
_prefix_path_locale = strdup(buf); _prefix_path_locale = strdup(buf);
@ -226,9 +231,6 @@ _e_prefix_share_hunt(void)
{ {
char buf[4096], buf2[4096], *p; char buf[4096], buf2[4096], *p;
FILE *f; FILE *f;
#ifdef PREFIX_CACHE_FILE
const char *home;
#endif
/* sometimes this isnt the case - so we need to do a more exhaustive search /* sometimes this isnt the case - so we need to do a more exhaustive search
* through more parent and subdirs. hre is an example i have seen: * through more parent and subdirs. hre is an example i have seen:
@ -245,9 +247,7 @@ _e_prefix_share_hunt(void)
#ifdef PREFIX_CACHE_FILE #ifdef PREFIX_CACHE_FILE
/* 1. check cache file - as a first attempt. this will speed up subsequent /* 1. check cache file - as a first attempt. this will speed up subsequent
* hunts - if needed */ * hunts - if needed */
home = e_user_homedir_get(); e_user_dir_concat_static(buf, "prefix_share_cache.txt");
snprintf(buf, sizeof(buf), "%s/.e/e/prefix_share_cache.txt", home);
f = fopen(buf, "r"); f = fopen(buf, "r");
if (f) if (f)
{ {
@ -262,7 +262,7 @@ _e_prefix_share_hunt(void)
{ {
/* path is ok - magic file found */ /* path is ok - magic file found */
_prefix_path_data = strdup(buf2); _prefix_path_data = strdup(buf2);
snprintf(buf, sizeof(buf), "%s", buf2); _prefix_path_data_len = ecore_strlcpy(buf, buf2, sizeof(buf));
p = strrchr(buf, '/'); p = strrchr(buf, '/');
if (p) *p = 0; if (p) *p = 0;
snprintf(buf2, sizeof(buf2), "%s/locale", buf); snprintf(buf2, sizeof(buf2), "%s/locale", buf);
@ -285,8 +285,8 @@ _e_prefix_share_hunt(void)
{ {
Eina_List *files; Eina_List *files;
Eina_List *l; Eina_List *l;
snprintf(buf, sizeof(buf), "%s", _prefix_path); ecore_strlcpy(buf, _prefix_path, sizeof(buf));
p = strrchr(buf, '/'); p = strrchr(buf, '/');
if (p) *p = 0; if (p) *p = 0;
files = ecore_file_ls(buf); files = ecore_file_ls(buf);
@ -299,17 +299,16 @@ _e_prefix_share_hunt(void)
snprintf(buf2, sizeof(buf2), "%s/%s/"MAGIC_DAT, buf, file); snprintf(buf2, sizeof(buf2), "%s/%s/"MAGIC_DAT, buf, file);
if (ecore_file_exists(buf2)) if (ecore_file_exists(buf2))
{ {
snprintf(buf2, sizeof(buf2), "%s/%s/"SHARE_D, buf, file); _prefix_path_data_len = snprintf(buf2, sizeof(buf2), "%s/%s/"SHARE_D, buf, file);
_prefix_path_data = strdup(buf2); _prefix_path_data = strdup(buf2);
snprintf(buf2, sizeof(buf2), "%s/%s/"LOCALE_D, buf, file); snprintf(buf2, sizeof(buf2), "%s/%s/"LOCALE_D, buf, file);
_prefix_path_locale = strdup(buf2); _prefix_path_locale = strdup(buf2);
break; break;
} }
} }
while (files) EINA_LIST_FREE(files, p)
{ {
free(eina_list_data_get(files)); free(p);
files = eina_list_remove_list(files, files);
} }
} }
} }
@ -320,13 +319,13 @@ _e_prefix_share_hunt(void)
*/ */
if (!_prefix_path_data) if (!_prefix_path_data)
{ {
snprintf(buf, sizeof(buf), "%s", _prefix_path); ecore_strlcpy(buf, _prefix_path, sizeof(buf));
p = strrchr(buf, '/'); p = strrchr(buf, '/');
if (p) *p = 0; if (p) *p = 0;
snprintf(buf2, sizeof(buf2), "%s/"MAGIC_DAT, buf); snprintf(buf2, sizeof(buf2), "%s/"MAGIC_DAT, buf);
if (ecore_file_exists(buf2)) if (ecore_file_exists(buf2))
{ {
snprintf(buf2, sizeof(buf2), "%s/"SHARE_D, buf); _prefix_path_data_len = snprintf(buf2, sizeof(buf2), "%s/"SHARE_D, buf);
_prefix_path_data = strdup(buf2); _prefix_path_data = strdup(buf2);
snprintf(buf2, sizeof(buf2), "%s/"LOCALE_D, buf); snprintf(buf2, sizeof(buf2), "%s/"LOCALE_D, buf);
_prefix_path_locale = strdup(buf2); _prefix_path_locale = strdup(buf2);
@ -343,9 +342,8 @@ _e_prefix_share_hunt(void)
if (_prefix_path_data) if (_prefix_path_data)
{ {
#ifdef PREFIX_CACHE_FILE #ifdef PREFIX_CACHE_FILE
snprintf(buf, sizeof(buf), "%s/.e/e", home); ecore_file_mkpath(e_user_dir_get());
ecore_file_mkpath(buf); e_user_dir_concat_static(buf, "prefix_share_cache.txt");
snprintf(buf, sizeof(buf), "%s/.e/e/prefix_share_cache.txt", home);
f = fopen(buf, "w"); f = fopen(buf, "w");
if (f) if (f)
{ {
@ -370,6 +368,7 @@ _e_prefix_fallbacks(void)
_prefix_path_locale = strdup(LOCALE_DIR); _prefix_path_locale = strdup(LOCALE_DIR);
_prefix_path_bin = strdup(PACKAGE_BIN_DIR); _prefix_path_bin = strdup(PACKAGE_BIN_DIR);
_prefix_path_data = strdup(PACKAGE_DATA_DIR); _prefix_path_data = strdup(PACKAGE_DATA_DIR);
_prefix_path_data_len = strlen(_prefix_path_data);
_prefix_path_lib = strdup(PACKAGE_LIB_DIR); _prefix_path_lib = strdup(PACKAGE_LIB_DIR);
printf("WARNING: Enlightenment could not determine its installed prefix\n" printf("WARNING: Enlightenment could not determine its installed prefix\n"
" and is falling back on the compiled in default:\n" " and is falling back on the compiled in default:\n"
@ -519,3 +518,38 @@ _e_prefix_try_argv(char *argv0)
/* 4. big problems. arg[0] != executable - weird execution */ /* 4. big problems. arg[0] != executable - weird execution */
return 0; return 0;
} }
size_t
e_prefix_data_concat_len(char *dst, size_t size, const char *path, size_t path_len)
{
return ecore_str_join_len(dst, size, '/', _prefix_path_data, _prefix_path_data_len, path, path_len);
}
size_t
e_prefix_data_snprintf(char *dst, size_t size, const char *fmt, ...)
{
size_t off, ret;
va_list ap;
va_start(ap, fmt);
off = _prefix_path_data_len + 1;
if (size < _prefix_path_data_len + 2)
{
if (size > 1)
{
memcpy(dst, _prefix_path_data, size - 1);
dst[size - 1] = '\0';
}
ret = off + vsnprintf(dst + off, size - off, fmt, ap);
va_end(ap);
return ret;
}
memcpy(dst, _prefix_path_data, _prefix_path_data_len);
dst[_prefix_path_data_len] = '/';
ret = off + vsnprintf(dst + off, size - off, fmt, ap);
va_end(ap);
return ret;
}

View File

@ -15,6 +15,16 @@ EAPI const char *e_prefix_locale_get(void);
EAPI const char *e_prefix_bin_get(void); EAPI const char *e_prefix_bin_get(void);
EAPI const char *e_prefix_data_get(void); EAPI const char *e_prefix_data_get(void);
EAPI const char *e_prefix_lib_get(void); EAPI const char *e_prefix_lib_get(void);
EAPI size_t e_prefix_data_concat_len(char *dst, size_t size, const char *path, size_t path_len);
EAPI size_t e_prefix_data_snprintf(char *dst, size_t size, const char *fmt, ...) EINA_PRINTF(3, 4);
static inline size_t e_prefix_data_concat(char *dst, size_t size, const char *path)
{
return e_prefix_data_concat_len(dst, size, path, strlen(path));
}
#define e_prefix_data_concat_static(dst, path) e_prefix_data_concat_len(dst, sizeof(dst), path, (sizeof(path) > 0) ? sizeof(path) - 1 : 0)
#endif #endif
#endif #endif

View File

@ -20,22 +20,18 @@ static int start_app_pos = -1;
EAPI void EAPI void
e_startup(E_Startup_Mode mode) e_startup(E_Startup_Mode mode)
{ {
const char *homedir, *prefixdir;
char buf[PATH_MAX]; char buf[PATH_MAX];
homedir = e_user_homedir_get();
prefixdir = e_prefix_data_get();
if (mode == E_STARTUP_START) if (mode == E_STARTUP_START)
{ {
snprintf(buf, sizeof(buf), "%s/.e/e/applications/startup/.order", homedir); e_user_dir_concat_static(buf, "applications/startup/.order");
if (!ecore_file_exists(buf)) if (!ecore_file_exists(buf))
snprintf(buf, sizeof(buf), "%s/data/applications/startup/.order", prefixdir); e_prefix_data_concat_static(buf, "data/applications/startup/.order");
} }
else if (mode == E_STARTUP_RESTART) else if (mode == E_STARTUP_RESTART)
{ {
snprintf(buf, sizeof(buf), "%s/.e/e/applications/restart/.order", homedir); e_user_dir_concat_static(buf, "applications/restart/.order");
if (!ecore_file_exists(buf)) if (!ecore_file_exists(buf))
snprintf(buf, sizeof(buf), "%s/data/applications/restart/.order", prefixdir); e_prefix_data_concat_static(buf, "data/applications/restart/.order");
} }
startup_apps = e_order_new(buf); startup_apps = e_order_new(buf);
if (!startup_apps) return; if (!startup_apps) return;

View File

@ -77,10 +77,9 @@ main(int argc, char **argv)
ecore_file_init(); ecore_file_init();
ecore_ipc_init(); ecore_ipc_init();
snprintf(_thumbdir, sizeof(_thumbdir), "%s/.e/e/fileman/thumbnails", e_user_dir_concat_static(_thumbdir, "fileman/thumbnails");
e_user_homedir_get());
ecore_file_mkpath(_thumbdir); ecore_file_mkpath(_thumbdir);
if (_e_ipc_init()) ecore_main_loop_begin(); if (_e_ipc_init()) ecore_main_loop_begin();
if (_e_ipc_server) if (_e_ipc_server)

View File

@ -3,22 +3,85 @@
*/ */
#include "e.h" #include "e.h"
static const char *_e_user_homedir = NULL;
static size_t _e_user_homedir_len = 0;
/* externally accessible functions */ /* externally accessible functions */
EAPI const char * EAPI const char *
e_user_homedir_get(void) e_user_homedir_get(void)
{ {
char *homedir; char *d;
int len;
homedir = getenv("HOME"); if (_e_user_homedir)
if (!homedir) return "/tmp"; return _e_user_homedir;
len = strlen(homedir);
while ((len > 1) && (homedir[len - 1] == '/')) _e_user_homedir = d = getenv("HOME");
if (!_e_user_homedir)
{ {
homedir[len - 1] = 0; _e_user_homedir = "/tmp";
len--; _e_user_homedir_len = sizeof("/tmp") - 1;
return _e_user_homedir;
} }
return homedir;
_e_user_homedir_len = strlen(_e_user_homedir);
while ((_e_user_homedir_len > 1) &&
(d[_e_user_homedir_len - 1] == '/'))
{
_e_user_homedir_len--;
d[_e_user_homedir_len] = '\0';
}
return _e_user_homedir;
}
/**
* Concatenate '~/' and @a path.
*
* @return similar to snprintf(), this returns the number of bytes written or
* that would be required to write if greater or equal than size.
*/
EAPI size_t
e_user_homedir_concat_len(char *dst, size_t size, const char *path, size_t path_len)
{
if (!_e_user_homedir)
e_user_homedir_get();
return ecore_str_join_len(dst, size, '/', _e_user_homedir, _e_user_homedir_len, path, path_len);
}
/**
* same as snprintf("~/"fmt, ...).
*/
EAPI size_t
e_user_homedir_snprintf(char *dst, size_t size, const char *fmt, ...)
{
size_t off, ret;
va_list ap;
if (!_e_user_homedir)
e_user_homedir_get();
va_start(ap, fmt);
off = _e_user_homedir_len + 1;
if (size < _e_user_homedir_len + 2)
{
if (size > 1)
{
memcpy(dst, _e_user_homedir, size - 1);
dst[size - 1] = '\0';
}
ret = off + vsnprintf(dst + off, size - off, fmt, ap);
va_end(ap);
return ret;
}
memcpy(dst, _e_user_homedir, _e_user_homedir_len);
dst[_e_user_homedir_len] = '/';
ret = off + vsnprintf(dst + off, size - off, fmt, ap);
va_end(ap);
return ret;
} }
/** /**
@ -52,3 +115,73 @@ e_user_icon_dir_get(void)
return dir; return dir;
} }
static const char *_e_user_dir = NULL;
static size_t _e_user_dir_len = 0;
/**
* Return ~/.e/e
*/
EAPI const char *
e_user_dir_get(void)
{
static char dir[PATH_MAX] = "";
if (!dir[0])
{
_e_user_dir_len = e_user_homedir_concat(dir, sizeof(dir), ".e/e");
_e_user_dir = dir;
}
return dir;
}
/**
* Concatenate '~/.e/e' and @a path.
*
* @return similar to snprintf(), this returns the number of bytes written or
* that would be required to write if greater or equal than size.
*/
EAPI size_t
e_user_dir_concat_len(char *dst, size_t size, const char *path, size_t path_len)
{
if (!_e_user_dir)
e_user_dir_get();
return ecore_str_join_len(dst, size, '/', _e_user_dir, _e_user_dir_len, path, path_len);
}
/**
* same as snprintf("~/.e/e/"fmt, ...).
*/
EAPI size_t
e_user_dir_snprintf(char *dst, size_t size, const char *fmt, ...)
{
size_t off, ret;
va_list ap;
if (!_e_user_dir)
e_user_dir_get();
va_start(ap, fmt);
off = _e_user_dir_len + 1;
if (size < _e_user_dir_len + 2)
{
if (size > 1)
{
memcpy(dst, _e_user_dir, size - 1);
dst[size - 1] = '\0';
}
ret = off + vsnprintf(dst + off, size - off, fmt, ap);
va_end(ap);
return ret;
}
memcpy(dst, _e_user_dir, _e_user_dir_len);
dst[_e_user_dir_len] = '/';
ret = off + vsnprintf(dst + off, size - off, fmt, ap);
va_end(ap);
return ret;
}

View File

@ -6,7 +6,28 @@
#ifndef E_USER_H #ifndef E_USER_H
#define E_USER_H #define E_USER_H
#include <Eina.h>
EAPI const char *e_user_homedir_get(void); EAPI const char *e_user_homedir_get(void);
EAPI size_t e_user_homedir_concat_len(char *dst, size_t size, const char *path, size_t path_len);
EAPI size_t e_user_homedir_snprintf(char *dst, size_t size, const char *fmt, ...) EINA_PRINTF(3, 4);
static inline size_t e_user_homedir_concat(char *dst, size_t size, const char *path)
{
return e_user_homedir_concat_len(dst, size, path, strlen(path));
}
#define e_user_homedir_concat_static(dst, path) e_user_homedir_concat_len(dst, sizeof(dst), path, (sizeof(path) > 0) ? sizeof(path) - 1 : 0)
EAPI const char *e_user_dir_get(void);
EAPI size_t e_user_dir_concat_len(char *dst, size_t size, const char *path, size_t path_len);
EAPI size_t e_user_dir_snprintf(char *dst, size_t size, const char *fmt, ...) EINA_PRINTF(3, 4);
static inline size_t e_user_dir_concat(char *dst, size_t size, const char *path)
{
return e_user_dir_concat_len(dst, size, path, strlen(path));
}
#define e_user_dir_concat_static(dst, path) e_user_dir_concat_len(dst, sizeof(dst), path, (sizeof(path) > 0) ? sizeof(path) - 1 : 0)
EAPI const char *e_user_desktop_dir_get(void); EAPI const char *e_user_desktop_dir_get(void);
EAPI const char *e_user_icon_dir_get(void); EAPI const char *e_user_icon_dir_get(void);

View File

@ -70,34 +70,39 @@ static void
_e_wid_fsel_favorites_add(void *data1, void *data2) _e_wid_fsel_favorites_add(void *data1, void *data2)
{ {
E_Widget_Data *wd; E_Widget_Data *wd;
const char *current_path, *homedir; const char *current_path;
char buf[4096], *fname; char buf[4096], *fname;
struct stat st; struct stat st;
int i = 1;
FILE *f; FILE *f;
size_t len;
wd = data1; wd = data1;
current_path = e_fm2_real_path_get(wd->o_files_fm); current_path = e_fm2_real_path_get(wd->o_files_fm);
if (!ecore_file_is_dir(current_path)) return; if (!ecore_file_is_dir(current_path)) return;
homedir = e_user_homedir_get();
snprintf(buf, sizeof(buf), "%s/.e/e/fileman/favorites/%s", len = e_user_dir_snprintf(buf, sizeof(buf), "fileman/favorites/%s",
homedir, ecore_file_file_get(current_path)); ecore_file_file_get(current_path));
if (len >= sizeof(buf)) return;
if (stat(buf, &st) < 0) symlink(current_path, buf); if (stat(buf, &st) < 0) symlink(current_path, buf);
else else
{ {
while (stat(buf, &st) == 0) unsigned int i = 1, maxlen;
buf[len] = '-';
len++;
if (len == sizeof(buf)) return;
maxlen = sizeof(buf) - len;
do
{ {
snprintf(buf, sizeof(buf), if (snprintf(buf + len, maxlen, "%d", i) >= maxlen)
"%s/.e/e/fileman/favorites/%s-%d", return;
homedir,
ecore_file_file_get(current_path), i);
i++; i++;
} }
symlink(current_path, buf); while (stat(buf, &st) == 0);
symlink(current_path, buf);
} }
fname = alloca(strlen(ecore_file_file_get(buf)) + 1); fname = alloca(strlen(ecore_file_file_get(buf)) + 1);
strcpy(fname, ecore_file_file_get(buf)); strcpy(fname, ecore_file_file_get(buf));
snprintf(buf, sizeof(buf), "%s/.e/e/fileman/favorites/.order", homedir); e_user_dir_concat_static(buf, "fileman/favorites/.order");
if (ecore_file_exists(buf)) if (ecore_file_exists(buf))
{ {
f = fopen(buf, "a"); f = fopen(buf, "a");

View File

@ -45,8 +45,7 @@ e_int_config_apps_favs(E_Container *con, const char *params __UNUSED__)
E_Config_Data *data; E_Config_Data *data;
char buf[4096]; char buf[4096];
snprintf(buf, sizeof(buf), "%s/.e/e/applications/menu/favorite.menu", e_user_dir_concat_static(buf, "applications/menu/favorite.menu");
e_user_homedir_get());
data = E_NEW(E_Config_Data, 1); data = E_NEW(E_Config_Data, 1);
data->title = eina_stringshare_add(_("Favorites Menu")); data->title = eina_stringshare_add(_("Favorites Menu"));
data->dialog = eina_stringshare_add("_config_apps_favs_dialog"); data->dialog = eina_stringshare_add("_config_apps_favs_dialog");
@ -100,8 +99,7 @@ e_int_config_apps_ibar(E_Container *con, const char *params __UNUSED__)
E_Config_Data *data; E_Config_Data *data;
char buf[4096]; char buf[4096];
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/default/.order", e_user_dir_concat_static(buf, "applications/bar/default/.order");
e_user_homedir_get());
data = E_NEW(E_Config_Data, 1); data = E_NEW(E_Config_Data, 1);
data->title = eina_stringshare_add(_("IBar Applications")); data->title = eina_stringshare_add(_("IBar Applications"));
data->dialog = eina_stringshare_add("_config_apps_ibar_dialog"); data->dialog = eina_stringshare_add("_config_apps_ibar_dialog");
@ -132,8 +130,7 @@ e_int_config_apps_startup(E_Container *con, const char *params __UNUSED__)
E_Config_Data *data; E_Config_Data *data;
char buf[4096]; char buf[4096];
snprintf(buf, sizeof(buf), "%s/.e/e/applications/startup/.order", e_user_dir_concat_static(buf, "applications/startup/.order");
e_user_homedir_get());
data = E_NEW(E_Config_Data, 1); data = E_NEW(E_Config_Data, 1);
data->title = eina_stringshare_add(_("Startup Applications")); data->title = eina_stringshare_add(_("Startup Applications"));
data->dialog = eina_stringshare_add("_config_apps_startup_dialog"); data->dialog = eina_stringshare_add("_config_apps_startup_dialog");
@ -149,8 +146,7 @@ e_int_config_apps_restart(E_Container *con, const char *params __UNUSED__)
E_Config_Data *data; E_Config_Data *data;
char buf[4096]; char buf[4096];
snprintf(buf, sizeof(buf), "%s/.e/e/applications/restart/.order", e_user_dir_concat_static(buf, "applications/restart/.order");
e_user_homedir_get());
data = E_NEW(E_Config_Data, 1); data = E_NEW(E_Config_Data, 1);
data->title = eina_stringshare_add(_("Restart Applications")); data->title = eina_stringshare_add(_("Restart Applications"));
data->dialog = eina_stringshare_add("_config_apps_restart_dialog"); data->dialog = eina_stringshare_add("_config_apps_restart_dialog");

View File

@ -213,9 +213,9 @@ _adv_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
e_widget_table_object_append(ft, cfdata->o_btn, 0, 1, 1, 1, 0, 0, 0, 0); e_widget_table_object_append(ft, cfdata->o_btn, 0, 1, 1, 1, 0, 0, 0, 0);
if (cfdata->fmdir == 1) if (cfdata->fmdir == 1)
snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); e_prefix_data_concat_static(path, "data/backgrounds");
else else
snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); e_user_dir_concat_static(path, "backgrounds");
ow = e_fm2_add(evas); ow = e_fm2_add(evas);
cfdata->o_fm = ow; cfdata->o_fm = ow;
@ -421,11 +421,11 @@ _cb_method_change(void *data, Evas_Object *obj, void *event_info)
if (!ic) return; if (!ic) return;
e_fm2_select_set(cfdata->o_fm, ic->file, 1); e_fm2_select_set(cfdata->o_fm, ic->file, 1);
if (cfdata->fmdir == 0) if (cfdata->fmdir == 0)
snprintf(path, sizeof(path), "%s/.e/e/backgrounds/%s", e_user_dir_snprintf(path, sizeof(path), "backgrounds/%s",
e_user_homedir_get(), ic->file); ic->file);
else else
snprintf(path, sizeof(path), "%s/data/backgrounds/%s", e_prefix_data_snprintf(path, sizeof(path), "data/backgrounds/%s",
e_prefix_data_get(), ic->file); ic->file);
if (ecore_file_is_dir(path)) return; if (ecore_file_is_dir(path)) return;
E_FREE(cfdata->bg); E_FREE(cfdata->bg);
cfdata->bg = strdup(path); cfdata->bg = strdup(path);
@ -442,10 +442,10 @@ _cb_radio_change(void *data, Evas_Object *obj)
cfdata = data; cfdata = data;
if (!cfdata->o_fm) return; if (!cfdata->o_fm) return;
if (cfdata->fmdir == 0) if (cfdata->fmdir == 0)
snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); e_user_dir_concat_static(path, "backgrounds");
else else
snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); e_prefix_data_concat_static(path, "%s/data/backgrounds");
e_fm2_path_set(cfdata->o_fm, path, "/"); e_fm2_path_set(cfdata->o_fm, path, "/");
} }
@ -503,13 +503,13 @@ _cb_fm_sel_change(void *data, Evas_Object *obj, void *event_info)
if (cfdata->fmdir == 0) if (cfdata->fmdir == 0)
{ {
snprintf(path, sizeof(path), "%s/.e/e/backgrounds/%s", e_user_dir_snprintf(path, sizeof(path), "backgrounds/%s",
e_user_homedir_get(), ic->file); ic->file);
} }
else else
{ {
snprintf(path, sizeof(path), "%s/data/backgrounds/%s", e_prefix_data_snprintf(path, sizeof(path), "data/backgrounds/%s",
e_prefix_data_get(), ic->file); ic->file);
} }
if (ecore_file_is_dir(path)) return; if (ecore_file_is_dir(path)) return;
E_FREE(cfdata->bg); E_FREE(cfdata->bg);
@ -525,7 +525,8 @@ _cb_fm_change(void *data, Evas_Object *obj, void *event_info)
E_Config_Dialog_Data *cfdata; E_Config_Dialog_Data *cfdata;
const char *p; const char *p;
char path[PATH_MAX]; char path[PATH_MAX];
size_t len;
cfdata = data; cfdata = data;
if (!cfdata->bg) return; if (!cfdata->bg) return;
if (!cfdata->o_fm) return; if (!cfdata->o_fm) return;
@ -536,16 +537,15 @@ _cb_fm_change(void *data, Evas_Object *obj, void *event_info)
} }
else else
return; return;
snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); len = e_user_dir_concat_static(path, "backgrounds");
if (!strncmp(cfdata->bg, path, strlen(path))) if (!strncmp(cfdata->bg, path, len))
p = cfdata->bg + strlen(path) + 1; p = cfdata->bg + len + 1;
else else
{ {
snprintf(path, sizeof(path), "%s/data/backgrounds", len = e_prefix_data_concat_static(path, "data/backgrounds");
e_prefix_data_get()); if (!strncmp(cfdata->bg, path, len))
if (!strncmp(cfdata->bg, path, strlen(path))) p = cfdata->bg + len + 1;
p = cfdata->bg + strlen(path) + 1;
else else
p = cfdata->bg; p = cfdata->bg;
} }

View File

@ -100,7 +100,6 @@ static Evas_Object *
_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) _create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{ {
Evas_Object *o, *of, *ot, *ob; Evas_Object *o, *of, *ot, *ob;
const char *dir;
char buf[PATH_MAX]; char buf[PATH_MAX];
o = e_widget_list_add(evas, 0, 0); o = e_widget_list_add(evas, 0, 0);
@ -127,8 +126,7 @@ _create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
e_widget_table_object_align_append(ot, cfdata->o_reset, 2, 0, 1, 1, 0, 1, 1, 1, 1.0, 0.5); e_widget_table_object_align_append(ot, cfdata->o_reset, 2, 0, 1, 1, 0, 1, 1, 1, 1.0, 0.5);
// if there is a system version of the profile - allow reset // if there is a system version of the profile - allow reset
dir = e_prefix_data_get(); e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s/", e_config_profile_get());
snprintf(buf, sizeof(buf), "%s/data/config/%s/", dir, e_config_profile_get());
if (ecore_file_is_dir(buf)) if (ecore_file_is_dir(buf))
e_widget_disabled_set(cfdata->o_reset, 0); e_widget_disabled_set(cfdata->o_reset, 0);
else else
@ -170,7 +168,7 @@ _ilist_fill(E_Config_Dialog_Data *cfdata)
Efreet_Desktop *desk = NULL; Efreet_Desktop *desk = NULL;
Evas_Object *ic; Evas_Object *ic;
char buf[PATH_MAX], *prof, *pdir; char buf[PATH_MAX], *prof, *pdir;
const char *label, *dir; const char *label;
prof = l->data; prof = l->data;
if (e_config_profile_get()) if (e_config_profile_get())
@ -182,8 +180,7 @@ _ilist_fill(E_Config_Dialog_Data *cfdata)
desk = efreet_desktop_get(buf); desk = efreet_desktop_get(buf);
if (!desk) if (!desk)
{ {
dir = e_prefix_data_get(); e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s/", prof);
snprintf(buf, sizeof(buf), "%s/data/config/%s/", dir, prof);
pdir = strdup(buf); pdir = strdup(buf);
if (pdir) if (pdir)
{ {
@ -199,7 +196,7 @@ _ilist_fill(E_Config_Dialog_Data *cfdata)
if ((desk) && (desk->icon) && (pdir)) if ((desk) && (desk->icon) && (pdir))
snprintf(buf, sizeof(buf), "%s/%s", pdir, desk->icon); snprintf(buf, sizeof(buf), "%s/%s", pdir, desk->icon);
else else
snprintf(buf, sizeof(buf), "%s/data/images/enlightenment.png", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/images/enlightenment.png");
ic = e_util_icon_add(buf, evas); ic = e_util_icon_add(buf, evas);
e_widget_ilist_append(cfdata->o_list, ic, label, _ilist_cb_selected, cfdata, prof); e_widget_ilist_append(cfdata->o_list, ic, label, _ilist_cb_selected, cfdata, prof);
if (pdir) free(pdir); if (pdir) free(pdir);
@ -221,7 +218,7 @@ static void
_ilist_cb_selected(void *data) _ilist_cb_selected(void *data)
{ {
E_Config_Dialog_Data *cfdata; E_Config_Dialog_Data *cfdata;
const char *cur_profile, *dir; const char *cur_profile;
unsigned char v; unsigned char v;
Efreet_Desktop *desk = NULL; Efreet_Desktop *desk = NULL;
char *pdir, buf[PATH_MAX]; char *pdir, buf[PATH_MAX];
@ -240,8 +237,7 @@ _ilist_cb_selected(void *data)
desk = efreet_desktop_get(buf); desk = efreet_desktop_get(buf);
if (!desk) if (!desk)
{ {
dir = e_prefix_data_get(); e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s/", cfdata->sel_profile);
snprintf(buf, sizeof(buf), "%s/data/config/%s/", dir, cfdata->sel_profile);
pdir = strdup(buf); pdir = strdup(buf);
if (pdir) if (pdir)
{ {

View File

@ -116,9 +116,10 @@ static void
_cb_files_files_changed(void *data, Evas_Object *obj, void *event_info) _cb_files_files_changed(void *data, Evas_Object *obj, void *event_info)
{ {
E_Config_Dialog_Data *cfdata; E_Config_Dialog_Data *cfdata;
const char *p, *homedir;
char buf[4096]; char buf[4096];
const char *p;
size_t len;
cfdata = data; cfdata = data;
if (!cfdata->splash) return; if (!cfdata->splash) return;
if (!cfdata->o_fm) return; if (!cfdata->o_fm) return;
@ -127,16 +128,15 @@ _cb_files_files_changed(void *data, Evas_Object *obj, void *event_info)
{ {
if (strncmp(p, cfdata->splash, strlen(p))) return; if (strncmp(p, cfdata->splash, strlen(p))) return;
} }
homedir = e_user_homedir_get(); len = e_user_dir_concat_static(buf, "themes");
snprintf(buf, sizeof(buf), "%s/.e/e/themes", homedir);
if (!p) return; if (!p) return;
if (!strncmp(cfdata->splash, buf, strlen(buf))) if (!strncmp(cfdata->splash, buf, len))
p = cfdata->splash + strlen(buf) + 1; p = cfdata->splash + len + 1;
else else
{ {
snprintf(buf, sizeof(buf), "%s/data/themes", e_prefix_data_get()); len = e_prefix_data_concat_static(buf, "data/themes");
if (!strncmp(cfdata->splash, buf, strlen(buf))) if (!strncmp(cfdata->splash, buf, len))
p = cfdata->splash + strlen(buf) + 1; p = cfdata->splash + len + 1;
else else
p = cfdata->splash; p = cfdata->splash;
} }
@ -149,17 +149,15 @@ _cb_dir(void *data, Evas_Object *obj, void *event_info)
{ {
E_Config_Dialog_Data *cfdata; E_Config_Dialog_Data *cfdata;
char path[4096]; char path[4096];
const char *homedir;
cfdata = data; cfdata = data;
if (cfdata->fmdir == 1) if (cfdata->fmdir == 1)
{ {
snprintf(path, sizeof(path), "%s/data/themes", e_prefix_data_get()); e_prefix_data_concat_static(path, "data/themes");
} }
else else
{ {
homedir = e_user_homedir_get(); e_user_dir_concat_static(path, "themes");
snprintf(path, sizeof(path), "%s/.e/e/themes", homedir);
} }
e_fm2_path_set(cfdata->o_fm, path, "/"); e_fm2_path_set(cfdata->o_fm, path, "/");
} }
@ -168,7 +166,7 @@ static void
_fill_data(E_Config_Dialog_Data *cfdata) _fill_data(E_Config_Dialog_Data *cfdata)
{ {
char path[4096]; char path[4096];
const char *homedir; size_t len;
cfdata->show_splash = e_config->show_splash; cfdata->show_splash = e_config->show_splash;
cfdata->splash = NULL; cfdata->splash = NULL;
@ -176,13 +174,12 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->splash = strdup(e_config->init_default_theme); cfdata->splash = strdup(e_config->init_default_theme);
else else
{ {
snprintf(path, sizeof(path), "%s/data/themes/default.edj", e_prefix_data_get()); e_prefix_data_concat_static(path, "data/themes/default.edj");
cfdata->splash = strdup(path); cfdata->splash = strdup(path);
} }
if (cfdata->splash[0] != '/') if (cfdata->splash[0] != '/')
{ {
homedir = e_user_homedir_get(); e_user_dir_snprintf(path, sizeof(path), "themes/%s", cfdata->splash);
snprintf(path, sizeof(path), "%s/.e/e/themes/%s", homedir, cfdata->splash);
if (ecore_file_exists(path)) if (ecore_file_exists(path))
{ {
E_FREE(cfdata->splash); E_FREE(cfdata->splash);
@ -190,7 +187,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
} }
else else
{ {
snprintf(path, sizeof(path), "%s/data/themes/%s", e_prefix_data_get(), cfdata->splash); e_prefix_data_snprintf(path, sizeof(path), "data/themes/%s", cfdata->splash);
if (ecore_file_exists(path)) if (ecore_file_exists(path))
{ {
E_FREE(cfdata->splash); E_FREE(cfdata->splash);
@ -198,9 +195,9 @@ _fill_data(E_Config_Dialog_Data *cfdata)
} }
} }
} }
snprintf(path, sizeof(path), "%s/data/themes", e_prefix_data_get()); len = e_prefix_data_concat_static(path, "data/themes");
if (!strncmp(cfdata->splash, path, strlen(path))) if (!strncmp(cfdata->splash, path, len))
cfdata->fmdir = 1; cfdata->fmdir = 1;
} }
@ -251,13 +248,10 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
{ {
Evas_Object *o, *ot, *of, *il, *ol; Evas_Object *o, *ot, *of, *il, *ol;
char path[4096]; char path[4096];
const char *homedir;
E_Fm2_Config fmc; E_Fm2_Config fmc;
E_Zone *z; E_Zone *z;
E_Radio_Group *rg; E_Radio_Group *rg;
homedir = e_user_homedir_get();
z = e_zone_current_get(cfd->con); z = e_zone_current_get(cfd->con);
ot = e_widget_table_add(evas, 0); ot = e_widget_table_add(evas, 0);
@ -284,9 +278,9 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
e_widget_table_object_append(ol, o, 0, 1, 1, 1, 0, 0, 0, 0); e_widget_table_object_append(ol, o, 0, 1, 1, 1, 0, 0, 0, 0);
if (cfdata->fmdir == 1) if (cfdata->fmdir == 1)
snprintf(path, sizeof(path), "%s/data/themes", e_prefix_data_get()); e_prefix_data_concat_static(path, "data/themes");
else else
snprintf(path, sizeof(path), "%s/.e/e/themes", homedir); e_user_dir_concat_static(path, "themes");
o = e_fm2_add(evas); o = e_fm2_add(evas);
cfdata->o_fm = o; cfdata->o_fm = o;

View File

@ -122,7 +122,7 @@ e_int_config_theme_update(E_Config_Dialog *dia, char *file)
cfdata->fmdir = 1; cfdata->fmdir = 1;
e_widget_radio_toggle_set(cfdata->o_personal, 1); e_widget_radio_toggle_set(cfdata->o_personal, 1);
snprintf(path, sizeof(path), "%s/.e/e/themes", e_user_homedir_get()); e_user_dir_concat_static(path, "themes");
eina_stringshare_del(cfdata->theme); eina_stringshare_del(cfdata->theme);
cfdata->theme = eina_stringshare_add(file); cfdata->theme = eina_stringshare_add(file);
@ -201,6 +201,7 @@ _cb_files_files_changed(void *data, Evas_Object *obj, void *event_info)
E_Config_Dialog_Data *cfdata; E_Config_Dialog_Data *cfdata;
const char *p; const char *p;
char buf[4096]; char buf[4096];
size_t len;
cfdata = data; cfdata = data;
if ((!cfdata->theme) || (!cfdata->o_fm)) return; if ((!cfdata->theme) || (!cfdata->o_fm)) return;
@ -212,14 +213,14 @@ _cb_files_files_changed(void *data, Evas_Object *obj, void *event_info)
} }
if (!p) return; if (!p) return;
snprintf(buf, sizeof(buf), "%s/.e/e/themes", e_user_homedir_get()); len = e_user_dir_concat_static(buf, "themes");
if (!strncmp(cfdata->theme, buf, strlen(buf))) if (!strncmp(cfdata->theme, buf, len))
p = cfdata->theme + strlen(buf) + 1; p = cfdata->theme + len + 1;
else else
{ {
snprintf(buf, sizeof(buf), "%s/data/themes", e_prefix_data_get()); len = e_prefix_data_concat_static(buf, "data/themes");
if (!strncmp(cfdata->theme, buf, strlen(buf))) if (!strncmp(cfdata->theme, buf, len))
p = cfdata->theme + strlen(buf) + 1; p = cfdata->theme + len + 1;
else else
p = cfdata->theme; p = cfdata->theme;
} }
@ -235,9 +236,9 @@ _cb_dir(void *data, Evas_Object *obj, void *event_info)
cfdata = data; cfdata = data;
if (cfdata->fmdir == 1) if (cfdata->fmdir == 1)
snprintf(path, sizeof(path), "%s/data/themes", e_prefix_data_get()); e_prefix_data_concat_static(path, "data/themes");
else else
snprintf(path, sizeof(path), "%s/.e/e/themes", e_user_homedir_get()); e_user_dir_concat_static(path, "themes");
e_widget_flist_path_set(cfdata->o_fm, path, "/"); e_widget_flist_path_set(cfdata->o_fm, path, "/");
} }
@ -305,20 +306,19 @@ _fill_data(E_Config_Dialog_Data *cfdata)
{ {
E_Config_Theme * c; E_Config_Theme * c;
char path[4096]; char path[4096];
size_t len;
c = e_theme_config_get("theme"); c = e_theme_config_get("theme");
if (c) if (c)
cfdata->theme = eina_stringshare_add(c->file); cfdata->theme = eina_stringshare_add(c->file);
else else
{ {
snprintf(path, sizeof(path), "%s/data/themes/default.edj", e_prefix_data_concat_static(path, "data/themes/default.edj");
e_prefix_data_get());
cfdata->theme = eina_stringshare_add(path); cfdata->theme = eina_stringshare_add(path);
} }
if (cfdata->theme[0] != '/') if (cfdata->theme[0] != '/')
{ {
snprintf(path, sizeof(path), "%s/.e/e/themes/%s", e_user_dir_snprintf(path, sizeof(path), "themes/%s", cfdata->theme);
e_user_homedir_get(), cfdata->theme);
if (ecore_file_exists(path)) if (ecore_file_exists(path))
{ {
eina_stringshare_del(cfdata->theme); eina_stringshare_del(cfdata->theme);
@ -326,8 +326,8 @@ _fill_data(E_Config_Dialog_Data *cfdata)
} }
else else
{ {
snprintf(path, sizeof(path), "%s/data/themes/%s", e_prefix_data_snprintf(path, sizeof(path), "data/themes/%s",
e_prefix_data_get(), cfdata->theme); cfdata->theme);
if (ecore_file_exists(path)) if (ecore_file_exists(path))
{ {
eina_stringshare_del(cfdata->theme); eina_stringshare_del(cfdata->theme);
@ -338,8 +338,8 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->theme_list = _get_theme_categories_list(); cfdata->theme_list = _get_theme_categories_list();
snprintf(path, sizeof(path), "%s/data/themes", e_prefix_data_get()); len = e_prefix_data_concat_static(path, "data/themes");
if (!strncmp(cfdata->theme, path, strlen(path))) if (!strncmp(cfdata->theme, path, len))
cfdata->fmdir = 1; cfdata->fmdir = 1;
} }
@ -405,9 +405,9 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
e_widget_table_object_append(ol, o, 0, 1, 1, 1, 0, 0, 0, 0); e_widget_table_object_append(ol, o, 0, 1, 1, 1, 0, 0, 0, 0);
if (cfdata->fmdir == 1) if (cfdata->fmdir == 1)
snprintf(path, sizeof(path), "%s/data/themes", e_prefix_data_get()); e_prefix_data_concat_static(path, "data/themes");
else else
snprintf(path, sizeof(path), "%s/.e/e/themes", e_user_homedir_get()); e_user_dir_concat_static(path, "themes");
o = e_widget_flist_add(evas); o = e_widget_flist_add(evas);
cfdata->o_fm = o; cfdata->o_fm = o;
@ -599,12 +599,10 @@ _files_ilist_nth_label_to_file(void *data, int n)
if (!cfdata->o_files_ilist) return NULL; if (!cfdata->o_files_ilist) return NULL;
if (n > cfdata->personal_file_count) if (n > cfdata->personal_file_count)
snprintf(file, sizeof(file), "%s/data/themes/%s.edj", e_prefix_data_snprintf(file, sizeof(file), "data/themes/%s.edj",
e_prefix_data_get(),
e_widget_ilist_nth_label_get(cfdata->o_files_ilist, n)); e_widget_ilist_nth_label_get(cfdata->o_files_ilist, n));
else else
snprintf(file, sizeof(file), "%s/.e/e/themes/%s.edj", e_user_dir_snprintf(file, sizeof(file), "themes/%s.edj",
e_user_homedir_get(),
e_widget_ilist_nth_label_get(cfdata->o_files_ilist, n)); e_widget_ilist_nth_label_get(cfdata->o_files_ilist, n));
return eina_stringshare_add(file); return eina_stringshare_add(file);
@ -787,14 +785,12 @@ _fill_files_ilist(E_Config_Dialog_Data *cfdata)
e_widget_ilist_clear(o); e_widget_ilist_clear(o);
/* Grab the "Personal" themes. */ /* Grab the "Personal" themes. */
snprintf(theme_dir, sizeof(theme_dir), "%s/.e/e/themes", e_user_dir_concat_static(theme_dir, "themes");
e_user_homedir_get());
cfdata->personal_file_count = cfdata->personal_file_count =
_ilist_files_add(cfdata, _("Personal"), theme_dir); _ilist_files_add(cfdata, _("Personal"), theme_dir);
/* Grab the "System" themes. */ /* Grab the "System" themes. */
snprintf(theme_dir, sizeof(theme_dir), e_prefix_data_concat_static(theme_dir, "data/themes");
"%s/data/themes", e_prefix_data_get());
_ilist_files_add(cfdata, _("System"), theme_dir); _ilist_files_add(cfdata, _("System"), theme_dir);
e_widget_ilist_go(o); e_widget_ilist_go(o);

View File

@ -242,15 +242,12 @@ _theme_import_cb_ok(void *data, void *data2)
E_Win *win; E_Win *win;
const char *path; const char *path;
const char *file; const char *file;
const char *homedir;
char buf[4096]; char buf[4096];
win = data; win = data;
import = win->data; import = win->data;
if (!import) return; if (!import) return;
homedir = e_user_homedir_get();
path = e_widget_fsel_selection_path_get(import->fsel_obj); path = e_widget_fsel_selection_path_get(import->fsel_obj);
E_FREE(import->cfdata->file); E_FREE(import->cfdata->file);
if (path) if (path)
@ -261,7 +258,7 @@ _theme_import_cb_ok(void *data, void *data2)
char *strip; char *strip;
file = ecore_file_file_get(import->cfdata->file); file = ecore_file_file_get(import->cfdata->file);
snprintf(buf, sizeof(buf), "%s/.e/e/themes/%s", homedir, file); e_user_dir_snprintf(buf, sizeof(buf), "themes/%s", file);
strip = ecore_file_strip_ext(file); strip = ecore_file_strip_ext(file);
if (!strip) if (!strip)

View File

@ -137,7 +137,7 @@ e_int_config_theme_web(E_Config_Dialog *parent)
ol = e_widget_list_add(e_win_evas_get(dia->win), 0, 1); ol = e_widget_list_add(e_win_evas_get(dia->win), 0, 1);
/* The Exchange Smart Object*/ /* The Exchange Smart Object*/
snprintf(usr_dir, sizeof(usr_dir), "%s/.e/e/themes", e_user_homedir_get()); e_user_dir_concat_static(usr_dir, "themes");
exsm = exchange_smart_object_add(e_win_evas_get(dia->win)); exsm = exchange_smart_object_add(e_win_evas_get(dia->win));
exchange_smart_object_remote_group_set(exsm, "Border"); exchange_smart_object_remote_group_set(exsm, "Border");
exchange_smart_object_local_path_set(exsm, usr_dir); exchange_smart_object_local_path_set(exsm, usr_dir);

View File

@ -122,7 +122,7 @@ e_int_config_wallpaper_update(E_Config_Dialog *dia, char *file)
cfdata = dia->cfdata; cfdata = dia->cfdata;
cfdata->fmdir = 1; cfdata->fmdir = 1;
e_widget_radio_toggle_set(cfdata->o_personal, 1); e_widget_radio_toggle_set(cfdata->o_personal, 1);
snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); e_user_dir_concat_static(path, "backgrounds");
E_FREE(cfdata->bg); E_FREE(cfdata->bg);
cfdata->bg = strdup(file); cfdata->bg = strdup(file);
cfdata->use_theme_bg = 0; cfdata->use_theme_bg = 0;
@ -255,6 +255,7 @@ _cb_files_files_changed(void *data, Evas_Object *obj, void *event_info)
E_Config_Dialog_Data *cfdata; E_Config_Dialog_Data *cfdata;
const char *p = NULL; const char *p = NULL;
char buf[PATH_MAX]; char buf[PATH_MAX];
size_t len;
cfdata = data; cfdata = data;
if ((!cfdata->bg) || (!cfdata->o_fm)) return; if ((!cfdata->bg) || (!cfdata->o_fm)) return;
@ -265,14 +266,14 @@ _cb_files_files_changed(void *data, Evas_Object *obj, void *event_info)
} }
else return; else return;
snprintf(buf, sizeof(buf), "%s/.e/e/backgrounds", e_user_homedir_get()); len = e_user_dir_concat_static(buf, "backgrounds");
if (!strncmp(cfdata->bg, buf, strlen(buf))) if (!strncmp(cfdata->bg, buf, len))
p = cfdata->bg + strlen(buf) + 1; p = cfdata->bg + len + 1;
else else
{ {
snprintf(buf, sizeof(buf), "%s/data/backgrounds", e_prefix_data_get()); len = e_prefix_data_concat_static(buf, "data/backgrounds");
if (!strncmp(cfdata->bg, buf, strlen(buf))) if (!strncmp(cfdata->bg, buf, len))
p = cfdata->bg + strlen(buf) + 1; p = cfdata->bg + len + 1;
else else
p = cfdata->bg; p = cfdata->bg;
} }
@ -351,9 +352,9 @@ _cb_dir(void *data, Evas_Object *obj, void *event_info)
cfdata = data; cfdata = data;
if (cfdata->fmdir == 1) if (cfdata->fmdir == 1)
snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); e_prefix_data_concat_static(path, "data/backgrounds");
else else
snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); e_user_dir_concat_static(path, "backgrounds");
e_widget_flist_path_set(cfdata->o_fm, path, "/"); e_widget_flist_path_set(cfdata->o_fm, path, "/");
} }
@ -444,13 +445,13 @@ _fill_data(E_Config_Dialog_Data *cfdata)
if (cfdata->bg) if (cfdata->bg)
{ {
const char *f; const char *f;
size_t len;
f = e_theme_edje_file_get("base/theme/backgrounds", f = e_theme_edje_file_get("base/theme/backgrounds",
"e/desktop/background"); "e/desktop/background");
if (!strcmp(cfdata->bg, f)) cfdata->use_theme_bg = 1; if (!strcmp(cfdata->bg, f)) cfdata->use_theme_bg = 1;
snprintf(path, sizeof(path), "%s/data/backgrounds", len = e_prefix_data_concat_static(path, "data/backgrounds");
e_prefix_data_get()); if (!strncmp(cfdata->bg, path, len)) cfdata->fmdir = 1;
if (!strncmp(cfdata->bg, path, strlen(path))) cfdata->fmdir = 1;
} }
else else
cfdata->use_theme_bg = 1; cfdata->use_theme_bg = 1;
@ -521,9 +522,9 @@ _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
e_widget_table_object_append(ot, ow, 0, 1, 1, 1, 0, 0, 0, 0); e_widget_table_object_append(ot, ow, 0, 1, 1, 1, 0, 0, 0, 0);
if (cfdata->fmdir == 1) if (cfdata->fmdir == 1)
snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); e_prefix_data_concat_static(path, "data/backgrounds");
else else
snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); e_user_dir_concat_static(path, "backgrounds");
ow = e_widget_flist_add(evas); ow = e_widget_flist_add(evas);
cfdata->o_fm = ow; cfdata->o_fm = ow;
@ -651,9 +652,9 @@ _adv_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
e_widget_table_object_append(ot, ow, 0, 1, 1, 1, 0, 0, 0, 0); e_widget_table_object_append(ot, ow, 0, 1, 1, 1, 0, 0, 0, 0);
if (cfdata->fmdir == 1) if (cfdata->fmdir == 1)
snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); e_prefix_data_concat_static(path, "data/backgrounds");
else else
snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); e_user_dir_concat_static(path, "backgrounds");
ow = e_widget_flist_add(evas); ow = e_widget_flist_add(evas);
cfdata->o_fm = ow; cfdata->o_fm = ow;

View File

@ -254,21 +254,22 @@ _import_edj_gen(Import *import)
Evas *evas; Evas *evas;
int fd, num = 1; int fd, num = 1;
const char *file; const char *file;
const char *homedir;
char buf[4096], cmd[4096], tmpn[4096]; char buf[4096], cmd[4096], tmpn[4096];
char *fstrip; char *fstrip;
FILE *f; FILE *f;
size_t len, off;
evas = e_win_evas_get(import->dia->win); evas = e_win_evas_get(import->dia->win);
file = import->cfdata->name; file = import->cfdata->name;
homedir = e_user_homedir_get();
fstrip = ecore_file_strip_ext(file); fstrip = ecore_file_strip_ext(file);
if (!fstrip) return; if (!fstrip) return;
snprintf(buf, sizeof(buf), "%s/.e/e/backgrounds/%s.edj", homedir, fstrip); len = e_user_dir_snprintf(buf, sizeof(buf), "backgrounds/%s.edj", fstrip);
if (len >= sizeof(buf)) return;
off = len - sizeof(".edj") - 1;
while (ecore_file_exists(buf)) while (ecore_file_exists(buf))
{ {
snprintf(buf, sizeof(buf), "%s/.e/e/backgrounds/%s-%i.edj", homedir, fstrip, num); snprintf(buf + off, sizeof(buf) - off, "-%d.edj", num);
num++; num++;
} }
free(fstrip); free(fstrip);

View File

@ -416,22 +416,23 @@ _import_edj_gen(Import *import)
Evas_Object *img; Evas_Object *img;
int fd, num = 1; int fd, num = 1;
int w = 0, h = 0; int w = 0, h = 0;
const char *file, *homedir, *locale; const char *file, *locale;
char buf[4096], cmd[4096], tmpn[4096], ipart[4096], enc[128]; char buf[4096], cmd[4096], tmpn[4096], ipart[4096], enc[128];
char *imgdir = NULL, *fstrip; char *imgdir = NULL, *fstrip;
int cr = 255, cg = 255, cb = 255, ca = 255; int cr = 255, cg = 255, cb = 255, ca = 255;
FILE *f; FILE *f;
size_t len, off;
evas = e_win_evas_get(import->win); evas = e_win_evas_get(import->win);
file = ecore_file_file_get(import->cfdata->file); file = ecore_file_file_get(import->cfdata->file);
homedir = e_user_homedir_get();
fstrip = ecore_file_strip_ext(file); fstrip = ecore_file_strip_ext(file);
if (!fstrip) return; if (!fstrip) return;
snprintf(buf, sizeof(buf), "%s/.e/e/backgrounds/%s.edj", homedir, fstrip); len = e_user_dir_snprintf(buf, sizeof(buf), "backgrounds/%s.edj", fstrip);
if (len >= sizeof(buf)) return;
off = len - sizeof(".edj") - 1;
while (ecore_file_exists(buf)) while (ecore_file_exists(buf))
{ {
snprintf(buf, sizeof(buf), "%s/.e/e/backgrounds/%s-%i.edj", snprintf(buf + off, sizeof(buf) - off, "-%d.edj", num);
homedir, fstrip, num);
num++; num++;
} }
free(fstrip); free(fstrip);
@ -664,7 +665,6 @@ _import_cb_ok(void *data, void *data2)
FSel *fsel; FSel *fsel;
E_Win *win; E_Win *win;
const char *file; const char *file;
const char *homedir;
char buf[4096]; char buf[4096];
int is_bg, is_theme; int is_bg, is_theme;
int r; int r;
@ -683,9 +683,7 @@ _import_cb_ok(void *data, void *data2)
} }
else else
{ {
homedir = e_user_homedir_get(); e_user_dir_snprintf(buf, sizeof(buf), "backgrounds/%s", file);
snprintf(buf, sizeof(buf), "%s/.e/e/backgrounds/%s",
homedir, file);
is_bg = edje_file_group_exists(import->cfdata->file, is_bg = edje_file_group_exists(import->cfdata->file,
"e/desktop/background"); "e/desktop/background");
@ -775,14 +773,12 @@ _fsel_cb_ok(void *data, void *data2)
{ {
int r; int r;
int is_bg, is_theme; int is_bg, is_theme;
const char *homedir, *file; const char *file;
char buf[4096]; char buf[4096];
r = 0; r = 0;
file = ecore_file_file_get(path); file = ecore_file_file_get(path);
homedir = e_user_homedir_get(); e_user_dir_snprintf(buf, sizeof(buf), "backgrounds/%s", file);
snprintf(buf, sizeof(buf), "%s/.e/e/backgrounds/%s",
homedir, file);
is_bg = edje_file_group_exists(path, is_bg = edje_file_group_exists(path,
"e/desktop/background"); "e/desktop/background");

View File

@ -132,7 +132,7 @@ e_int_config_wallpaper_web(E_Config_Dialog *parent)
ol = e_widget_list_add(e_win_evas_get(dia->win), 0, 1); ol = e_widget_list_add(e_win_evas_get(dia->win), 0, 1);
/* The Exchange Smart Object*/ /* The Exchange Smart Object*/
snprintf(usr_dir, sizeof(usr_dir), "%s/.e/e/backgrounds", e_user_homedir_get()); e_user_dir_concat_static(usr_dir, "backgrounds");
exsm = exchange_smart_object_add(e_win_evas_get(dia->win)); exsm = exchange_smart_object_add(e_win_evas_get(dia->win));
exchange_smart_object_remote_group_set(exsm, "Wallpaper"); exchange_smart_object_remote_group_set(exsm, "Wallpaper");
exchange_smart_object_local_path_set(exsm, usr_dir); exchange_smart_object_local_path_set(exsm, usr_dir);

View File

@ -851,9 +851,9 @@ wp_browser_new(E_Container *con)
info->win = win; info->win = win;
win->data = info; win->data = info;
snprintf(buf, sizeof(buf), "%s/.e/e/backgrounds", e_user_homedir_get()); e_user_dir_concat_static(buf, "backgrounds");
info->dirs = eina_list_append(info->dirs, strdup(buf)); info->dirs = eina_list_append(info->dirs, strdup(buf));
snprintf(buf, sizeof(buf), "%s/data/backgrounds", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/backgrounds");
info->dirs = eina_list_append(info->dirs, strdup(buf)); info->dirs = eina_list_append(info->dirs, strdup(buf));
e_win_title_set(win, _("Wallpaper Settings")); e_win_title_set(win, _("Wallpaper Settings"));

View File

@ -197,9 +197,9 @@ _adv_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfda
if (cfdata->fmdir == 1) if (cfdata->fmdir == 1)
snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); e_prefix_data_concat_static(path, "data/backgrounds");
else else
snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); e_user_dir_concat_static(path, "backgrounds");
ow = e_fm2_add(evas); ow = e_fm2_add(evas);
cfdata->o_fm = ow; cfdata->o_fm = ow;
@ -362,13 +362,13 @@ _cb_fm_radio_change(void *data, Evas_Object *obj)
{ {
E_Config_Dialog_Data *cfdata; E_Config_Dialog_Data *cfdata;
char path[PATH_MAX]; char path[PATH_MAX];
cfdata = data; cfdata = data;
if (!cfdata->o_fm) return; if (!cfdata->o_fm) return;
if (cfdata->fmdir == 0) if (cfdata->fmdir == 0)
snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); e_user_dir_concat_static(path, "backgrounds");
else else
snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); e_prefix_data_concat_static(path, "data/backgrounds");
e_fm2_path_set(cfdata->o_fm, path, "/"); e_fm2_path_set(cfdata->o_fm, path, "/");
} }
@ -378,6 +378,7 @@ _cb_fm_change(void *data, Evas_Object *obj, void *event_info)
E_Config_Dialog_Data *cfdata; E_Config_Dialog_Data *cfdata;
const char *p; const char *p;
char path[PATH_MAX]; char path[PATH_MAX];
size_t len;
cfdata = data; cfdata = data;
if (!Man->conf->custom_bg) return; if (!Man->conf->custom_bg) return;
@ -388,14 +389,14 @@ _cb_fm_change(void *data, Evas_Object *obj, void *event_info)
if (strncmp(p, Man->conf->custom_bg, strlen(p))) return; if (strncmp(p, Man->conf->custom_bg, strlen(p))) return;
snprintf(path, sizeof(path), "%s/.e/e/backgrounds", e_user_homedir_get()); len = e_user_dir_concat_static(path, "backgrounds");
if (!strncmp(Man->conf->custom_bg, path, strlen(path))) if (!strncmp(Man->conf->custom_bg, path, len))
p = Man->conf->custom_bg + strlen(path) + 1; p = Man->conf->custom_bg + len + 1;
else else
{ {
snprintf(path, sizeof(path), "%s/data/backgrounds", e_prefix_data_get()); len = e_prefix_data_concat_static(path, "data/backgrounds");
if (!strncmp(Man->conf->custom_bg, path, strlen(path))) if (!strncmp(Man->conf->custom_bg, path, len))
p = Man->conf->custom_bg + strlen(path) + 1; p = Man->conf->custom_bg + len + 1;
else else
p = Man->conf->custom_bg; p = Man->conf->custom_bg;
} }

View File

@ -197,8 +197,7 @@ _cb_config(void *data, void *data2)
E_Config_Dialog_Data *cfdata; E_Config_Dialog_Data *cfdata;
cfdata = data; cfdata = data;
snprintf(path, sizeof(path), "%s/.e/e/applications/bar/%s/.order", e_user_dir_snprintf(path, sizeof(path), "applications/bar/%s/.order", cfdata->dir);
e_user_homedir_get(), cfdata->dir);
e_configure_registry_call("internal/ibar_other", e_configure_registry_call("internal/ibar_other",
e_container_current_get(e_manager_current_get()), e_container_current_get(e_manager_current_get()),
path); path);
@ -210,17 +209,16 @@ _cb_entry_ok(char *text, void *data)
char buf[4096]; char buf[4096];
char tmp[4096]; char tmp[4096];
FILE *f; FILE *f;
size_t len;
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s",
e_user_homedir_get(), text);
if (!ecore_file_exists(buf)) len = e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s", text);
if (len + sizeof("/.order") >= sizeof(buf)) return;
if (!ecore_file_exists(buf))
{ {
ecore_file_mkdir(buf); ecore_file_mkdir(buf);
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s/.order", memcpy(buf + len, "/.order", sizeof("/.order"));
e_user_homedir_get(), text);
f = fopen(buf, "w"); f = fopen(buf, "w");
if (f) if (f)
{ {
/* Populate this .order file with some defaults */ /* Populate this .order file with some defaults */
snprintf(tmp, sizeof(tmp), "xterm.desktop\n" "sylpheed.desktop\n" snprintf(tmp, sizeof(tmp), "xterm.desktop\n" "sylpheed.desktop\n"
@ -239,12 +237,13 @@ _cb_confirm_dialog_yes(void *data)
{ {
E_Config_Dialog_Data *cfdata; E_Config_Dialog_Data *cfdata;
char buf[4096]; char buf[4096];
cfdata = data; cfdata = data;
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s", e_user_homedir_get(), cfdata->dir); if (e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s", cfdata->dir) >= sizeof(buf))
return;
if (ecore_file_is_dir(buf)) if (ecore_file_is_dir(buf))
ecore_file_recursive_rm(buf); ecore_file_recursive_rm(buf);
_load_tlist(cfdata); _load_tlist(cfdata);
} }
@ -261,30 +260,35 @@ static void
_load_tlist(E_Config_Dialog_Data *cfdata) _load_tlist(E_Config_Dialog_Data *cfdata)
{ {
Eina_List *dirs; Eina_List *dirs;
const char *home;
char buf[4096], *file; char buf[4096], *file;
int selnum = -1; int selnum = -1;
int i = 0; int i = 0;
size_t len;
e_widget_ilist_clear(cfdata->tlist); e_widget_ilist_clear(cfdata->tlist);
home = e_user_homedir_get(); len = e_user_dir_concat_static(buf, "applications/bar");
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar", home); if (len + 2 >= sizeof(buf)) return;
dirs = ecore_file_ls(buf); dirs = ecore_file_ls(buf);
buf[len] = '/';
len++;
EINA_LIST_FREE(dirs, file) EINA_LIST_FREE(dirs, file)
{
if (file[0] == '.') continue;
if (ecore_strlcpy(buf + len, file, sizeof(buf) - len) >= sizeof(buf) - len)
continue;
if (ecore_file_is_dir(buf))
{ {
if (file[0] == '.') continue; e_widget_ilist_append(cfdata->tlist, NULL, file, NULL, NULL, file);
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s", home, file); if ((cfdata->dir) && (!strcmp(cfdata->dir, file)))
if (ecore_file_is_dir(buf)) selnum = i;
{ i++;
e_widget_ilist_append(cfdata->tlist, NULL, file, NULL, NULL, file); }
if ((cfdata->dir) && (!strcmp(cfdata->dir, file)))
selnum = i;
i++;
}
free(file); free(file);
} }
e_widget_ilist_go(cfdata->tlist); e_widget_ilist_go(cfdata->tlist);
if (selnum >= 0) if (selnum >= 0)

View File

@ -277,10 +277,7 @@ _ibar_new(Evas *evas, Instance *inst)
e_box_align_set(b->o_box, 0.5, 0.5); e_box_align_set(b->o_box, 0.5, 0.5);
if (inst->ci->dir[0] != '/') if (inst->ci->dir[0] != '/')
{ {
const char *homedir; e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s/.order", inst->ci->dir);
homedir = e_user_homedir_get();
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s/.order", homedir, inst->ci->dir);
} }
else else
ecore_strlcpy(buf, inst->ci->dir, sizeof(buf)); ecore_strlcpy(buf, inst->ci->dir, sizeof(buf));
@ -496,10 +493,7 @@ _ibar_config_update(Config_Item *ci)
e_object_del(E_OBJECT(inst->ibar->apps)); e_object_del(E_OBJECT(inst->ibar->apps));
if (inst->ci->dir[0] != '/') if (inst->ci->dir[0] != '/')
{ {
const char *homedir; e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s/.order", inst->ci->dir);
homedir = e_user_homedir_get();
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s/.order", homedir, inst->ci->dir);
} }
else else
ecore_strlcpy(buf, inst->ci->dir, sizeof(buf)); ecore_strlcpy(buf, inst->ci->dir, sizeof(buf));

View File

@ -835,11 +835,8 @@ _e_kbd_dbus_ignore_keyboards_file_load(const char *file)
static void static void
_e_kbd_dbus_ignore_keyboards_load(void) _e_kbd_dbus_ignore_keyboards_load(void)
{ {
const char *homedir;
char buf[PATH_MAX]; char buf[PATH_MAX];
e_user_dir_concat_static(buf, "keyboards/ignore_built_in_keyboards");
homedir = e_user_homedir_get();
snprintf(buf, sizeof(buf), "%s/.e/e/keyboards/ignore_built_in_keyboards", homedir);
_e_kbd_dbus_ignore_keyboards_file_load(buf); _e_kbd_dbus_ignore_keyboards_file_load(buf);
snprintf(buf, sizeof(buf), "%s/keyboards/ignore_built_in_keyboards", e_module_dir_get(mod)); snprintf(buf, sizeof(buf), "%s/keyboards/ignore_built_in_keyboards", e_module_dir_get(mod));
_e_kbd_dbus_ignore_keyboards_file_load(buf); _e_kbd_dbus_ignore_keyboards_file_load(buf);

View File

@ -225,14 +225,12 @@ _e_kbd_buf_cb_data_dict_reload(void *data)
{ {
E_Kbd_Buf *kb; E_Kbd_Buf *kb;
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *homedir;
kb = data; kb = data;
kb->dict.data_reload_delay = NULL; kb->dict.data_reload_delay = NULL;
e_kbd_buf_clear(kb); e_kbd_buf_clear(kb);
if (kb->dict.data) e_kbd_dict_free(kb->dict.data); if (kb->dict.data) e_kbd_dict_free(kb->dict.data);
homedir = e_user_homedir_get(); e_user_dir_concat_static(buf, "dicts-dynamic/data.dic");
snprintf(buf, sizeof(buf), "%s/.e/e/dicts-dynamic/data.dic", homedir);
kb->dict.data = e_kbd_dict_new(buf); kb->dict.data = e_kbd_dict_new(buf);
return 0; return 0;
} }
@ -252,28 +250,26 @@ e_kbd_buf_new(const char *sysdicts, const char *dict)
{ {
E_Kbd_Buf *kb; E_Kbd_Buf *kb;
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *homedir;
kb = E_NEW(E_Kbd_Buf, 1); kb = E_NEW(E_Kbd_Buf, 1);
if (!kb) return NULL; if (!kb) return NULL;
kb->sysdicts = evas_stringshare_add(sysdicts); kb->sysdicts = evas_stringshare_add(sysdicts);
homedir = e_user_homedir_get(); e_user_dir_concat_static(buf, "dicts");
snprintf(buf, sizeof(buf), "%s/.e/e/dicts", homedir);
if (!ecore_file_exists(buf)) ecore_file_mkpath(buf); if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
snprintf(buf, sizeof(buf), "%s/.e/e/dicts/%s", homedir, dict); e_user_dir_snprintf(buf, sizeof(buf), "dicts/%s", dict);
kb->dict.sys = e_kbd_dict_new(buf); kb->dict.sys = e_kbd_dict_new(buf);
if (!kb->dict.sys) if (!kb->dict.sys)
{ {
snprintf(buf, sizeof(buf), "%s/dicts/%s", kb->sysdicts, dict); snprintf(buf, sizeof(buf), "%s/dicts/%s", kb->sysdicts, dict);
kb->dict.sys = e_kbd_dict_new(buf); kb->dict.sys = e_kbd_dict_new(buf);
} }
snprintf(buf, sizeof(buf), "%s/.e/e/dicts-dynamic", homedir); e_user_dir_concat_static(buf, "dicts-dynamic");
if (!ecore_file_exists(buf)) ecore_file_mkpath(buf); if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
snprintf(buf, sizeof(buf), "%s/.e/e/dicts-dynamic/personal.dic", homedir); e_user_dir_concat_static(buf, "dicts-dynamic/personal.dic");
kb->dict.personal = e_kbd_dict_new(buf); kb->dict.personal = e_kbd_dict_new(buf);
if (!kb->dict.personal) if (!kb->dict.personal)
{ {
@ -287,7 +283,7 @@ e_kbd_buf_new(const char *sysdicts, const char *dict)
} }
kb->dict.personal = e_kbd_dict_new(buf); kb->dict.personal = e_kbd_dict_new(buf);
} }
snprintf(buf, sizeof(buf), "%s/.e/e/dicts-dynamic/data.dic", homedir); e_user_dir_concat_static(buf, "dicts-dynamic/data.dic");
kb->dict.data = e_kbd_dict_new(buf); kb->dict.data = e_kbd_dict_new(buf);
kb->dict.data_monitor = kb->dict.data_monitor =
ecore_file_monitor_add(buf, _e_kbd_buf_cb_data_dict_change, kb); ecore_file_monitor_add(buf, _e_kbd_buf_cb_data_dict_change, kb);
@ -313,17 +309,15 @@ EAPI void
e_kbd_buf_dict_set(E_Kbd_Buf *kb, const char *dict) e_kbd_buf_dict_set(E_Kbd_Buf *kb, const char *dict)
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *homedir;
e_kbd_buf_clear(kb); e_kbd_buf_clear(kb);
if (kb->dict.sys) e_kbd_dict_free(kb->dict.sys); if (kb->dict.sys) e_kbd_dict_free(kb->dict.sys);
homedir = e_user_homedir_get(); e_user_dir_concat_static(buf, "dicts");
snprintf(buf, sizeof(buf), "%s/.e/e/dicts", homedir);
if (!ecore_file_exists(buf)) ecore_file_mkpath(buf); if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
snprintf(buf, sizeof(buf), "%s/.e/e/dicts/%s", homedir, dict); e_user_dir_snprintf(buf, sizeof(buf), "dicts/%s", dict);
kb->dict.sys = e_kbd_dict_new(buf); kb->dict.sys = e_kbd_dict_new(buf);
if (!kb->dict.sys) if (!kb->dict.sys)
{ {

View File

@ -1067,48 +1067,61 @@ _e_kbd_int_layouts_list_update(E_Kbd_Int *ki)
Eina_List *files; Eina_List *files;
Eina_List *l; Eina_List *l;
char buf[PATH_MAX], *p, *file; char buf[PATH_MAX], *p, *file;
const char *homedir, *fl; const char *fl;
char *path; char *path;
Eina_List *kbs = NULL, *layouts = NULL; Eina_List *kbs = NULL, *layouts = NULL;
int ok; int ok;
size_t len;
homedir = e_user_homedir_get();
snprintf(buf, sizeof(buf), "%s/.e/e/keyboards", homedir); len = e_user_dir_concat_static(buf, "keyboards");
if (len + 2 >= sizeof(buf)) return;
files = ecore_file_ls(buf); files = ecore_file_ls(buf);
buf[len] = '/';
len++;
EINA_LIST_FREE(files, file) EINA_LIST_FREE(files, file)
{
p = strrchr(file, '.');
if ((p) && (!strcmp(p, ".kbd")))
{ {
p = strrchr(file, '.'); if (ecore_strlcpy(buf + len, file, sizeof(buf) - len) >= sizeof(buf) - len)
if ((p) && (!strcmp(p, ".kbd"))) continue;
{ kbs = eina_list_append(kbs, evas_stringshare_add(buf));
snprintf(buf, sizeof(buf), "%s/.e/e/keyboards/%s", homedir, file); }
kbs = eina_list_append(kbs, evas_stringshare_add(buf));
}
free(file); free(file);
} }
snprintf(buf, sizeof(buf), "%s/keyboards", ki->syskbds); len = snprintf(buf, sizeof(buf), "%s/keyboards", ki->syskbds);
if (len + 2 >= sizeof(buf)) return;
files = ecore_file_ls(buf); files = ecore_file_ls(buf);
buf[len] = '/';
len++;
EINA_LIST_FREE(files, file) EINA_LIST_FREE(files, file)
{
p = strrchr(file, '.');
if ((p) && (!strcmp(p, ".kbd")))
{ {
p = strrchr(file, '.'); ok = 1;
if ((p) && (!strcmp(p, ".kbd"))) EINA_LIST_FOREACH(kbs, l, fl)
{ {
ok = 1; if (!strcmp(file, fl))
for (l = kbs; l; l = l->next)
{ {
fl = ecore_file_file_get(l->data); ok = 0;
if (!strcmp(file, fl)) break;
{
ok = 0;
break;
}
}
if (ok)
{
snprintf(buf, sizeof(buf), "%s/keyboards/%s", ki->syskbds, file);
kbs = eina_list_append(kbs, evas_stringshare_add(buf));
} }
} }
if (ok)
{
if (ecore_strlcpy(buf + len, file, sizeof(buf) - len) >= sizeof(buf) - len)
continue;
kbs = eina_list_append(kbs, evas_stringshare_add(buf));
}
}
free(file); free(file);
} }
/* Previous loop could break before destroying all items. */ /* Previous loop could break before destroying all items. */
@ -1356,7 +1369,7 @@ _e_kbd_int_dictlist_up(E_Kbd_Int *ki)
Eina_List *files; Eina_List *files;
Eina_List *l; Eina_List *l;
char buf[PATH_MAX], *p, *file, *pp; char buf[PATH_MAX], *p, *file, *pp;
const char *homedir, *str; const char *str;
int used; int used;
if (ki->dictlist.popup) return; if (ki->dictlist.popup) return;
@ -1372,8 +1385,7 @@ _e_kbd_int_dictlist_up(E_Kbd_Int *ki)
e_widget_ilist_freeze(o); e_widget_ilist_freeze(o);
ki->dictlist.ilist_obj = o; ki->dictlist.ilist_obj = o;
homedir = e_user_homedir_get(); e_user_dir_concat_static(buf, "dicts");
snprintf(buf, sizeof(buf), "%s/.e/e/dicts", homedir);
files = ecore_file_ls(buf); files = ecore_file_ls(buf);
EINA_LIST_FREE(files, file) EINA_LIST_FREE(files, file)

View File

@ -943,12 +943,13 @@ _cb_slipshelf_home2(const void *data, E_Slipshelf *ess, E_Border *pbd)
static void static void
_apps_unpopulate(void) _apps_unpopulate(void)
{ {
char buf[PATH_MAX], *homedir; char buf[PATH_MAX];
Efreet_Desktop *desktop; Efreet_Desktop *desktop;
Evas_Object *obj; Evas_Object *obj;
Eina_List *files; Eina_List *files;
char *file; char *file;
size_t len;
EINA_LIST_FREE(sels, obj) EINA_LIST_FREE(sels, obj)
evas_object_del(obj); evas_object_del(obj);
@ -964,13 +965,19 @@ _apps_unpopulate(void)
if (sf) evas_object_del(sf); if (sf) evas_object_del(sf);
sf = NULL; sf = NULL;
homedir = e_user_homedir_get(); len = e_user_dir_concat_static(buf, "appshadow");
snprintf(buf, sizeof(buf), "%s/.e/e/appshadow", homedir); if (len + 2 >= sizeof(buf)) return;
files = ecore_file_ls(buf); files = ecore_file_ls(buf);
buf[len] = '/';
len++;
EINA_LIST_FREE(files, file) EINA_LIST_FREE(files, file)
{ {
snprintf(buf, sizeof(buf), "%s/.e/e/appshadow/%s", homedir, file); if (ecore_strlcpy(buf + len, file, sizeof(buf) - len) >= sizeof(buf) - len)
ecore_file_unlink(buf); continue;
ecore_file_unlink(buf);
free(file); free(file);
} }
} }
@ -1006,7 +1013,6 @@ _apps_populate(void)
Evas_Coord mw, mh, sfw, sfh; Evas_Coord mw, mh, sfw, sfh;
Evas_Object *o = NULL; Evas_Object *o = NULL;
char buf[PATH_MAX]; char buf[PATH_MAX];
char *homedir = NULL;
int num = 0; int num = 0;
sf = e_scrollframe_add(evas); sf = e_scrollframe_add(evas);
@ -1027,8 +1033,7 @@ _apps_populate(void)
} }
else else
{ {
homedir = e_user_homedir_get(); e_user_dir_concat_static(buf, "appshadow");
snprintf(buf, sizeof(buf), "%s/.e/e/appshadow", homedir);
ecore_file_mkpath(buf); ecore_file_mkpath(buf);
fm = e_fm2_add(evas); fm = e_fm2_add(evas);
_apps_fm_config(fm); _apps_fm_config(fm);
@ -1126,7 +1131,7 @@ _apps_populate(void)
{ {
if (desktop) if (desktop)
{ {
snprintf(buf, sizeof(buf), "%s/.e/e/appshadow/%04x.desktop", homedir, num); e_user_dir_snprintf(buf, sizeof(buf), "appshadow/%04x.desktop", num);
ecore_file_symlink(desktop->orig_path, buf); ecore_file_symlink(desktop->orig_path, buf);
} }
num++; num++;
@ -1173,8 +1178,7 @@ _apps_populate(void)
// _e_illume_pan_get, // _e_illume_pan_get,
// _e_illume_pan_max_get, // _e_illume_pan_max_get,
// _e_illume_pan_child_size_get); // _e_illume_pan_child_size_get);
homedir = e_user_homedir_get(); e_user_dir_concat_static(buf, "appshadow");
snprintf(buf, sizeof(buf), "%s/.e/e/appshadow", homedir);
e_fm2_path_set(fm, NULL, buf); e_fm2_path_set(fm, NULL, buf);
evas_object_show(fm); evas_object_show(fm);
evas_object_smart_callback_add(fm, "selected", evas_object_smart_callback_add(fm, "selected",

View File

@ -149,11 +149,9 @@ wizard_page_show(E_Wizard_Page *pg)
E_Intl_Pair *pair; E_Intl_Pair *pair;
Evas_Object *ic; Evas_Object *ic;
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *dir;
pair = l->data; pair = l->data;
dir = e_prefix_data_get(); e_prefix_data_snprintf(buf, sizeof(buf), "data/images/%s", pair->locale_icon);
snprintf(buf, sizeof(buf), "%s/data/images/%s", dir, pair->locale_icon);
ic = e_util_icon_add(buf, pg->evas); ic = e_util_icon_add(buf, pg->evas);
e_widget_ilist_append(ob, ic, _(pair->locale_translation), e_widget_ilist_append(ob, ic, _(pair->locale_translation),
NULL, NULL, pair->locale_key); NULL, NULL, pair->locale_key);

View File

@ -13,9 +13,8 @@ _profile_change(void *data, Evas_Object *obj)
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *dir; const char *dir;
Efreet_Desktop *desk = NULL; Efreet_Desktop *desk = NULL;
dir = e_prefix_data_get(); e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s", profile);
snprintf(buf, sizeof(buf), "%s/data/config/%s", dir, profile);
dir = strdup(buf); dir = strdup(buf);
if (!dir) if (!dir)
{ {
@ -80,8 +79,7 @@ wizard_page_show(E_Wizard_Page *pg)
continue; continue;
} }
} }
dir = e_prefix_data_get(); e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s", prof);
snprintf(buf, sizeof(buf), "%s/data/config/%s", dir, prof);
// if it's not a system profile - don't offer it // if it's not a system profile - don't offer it
if (!ecore_file_is_dir(buf)) if (!ecore_file_is_dir(buf))
{ {
@ -102,7 +100,7 @@ wizard_page_show(E_Wizard_Page *pg)
if ((desk) && (desk->icon)) if ((desk) && (desk->icon))
snprintf(buf, sizeof(buf), "%s/%s", dir, desk->icon); snprintf(buf, sizeof(buf), "%s/%s", dir, desk->icon);
else else
snprintf(buf, sizeof(buf), "%s/data/images/enlightenment.png", e_prefix_data_get()); e_prefix_data_concat_static(buf, "data/images/enlightenment.png");
ic = e_util_icon_add(buf, pg->evas); ic = e_util_icon_add(buf, pg->evas);
e_widget_ilist_append(ob, ic, label, NULL, NULL, prof); e_widget_ilist_append(ob, ic, label, NULL, NULL, prof);
free(prof); free(prof);
@ -141,10 +139,8 @@ wizard_page_hide(E_Wizard_Page *pg)
if (e_config_profile_get()) if (e_config_profile_get())
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *homedir; if (e_user_dir_snprintf(buf, sizeof(buf), "config/%s", e_config_profile_get()) >= sizeof(buf))
homedir = e_user_homedir_get(); return 1;
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s", homedir, e_config_profile_get());
ecore_file_recursive_rm(buf); ecore_file_recursive_rm(buf);
} }
if (!profile) profile = "standard"; if (!profile) profile = "standard";

View File

@ -112,12 +112,10 @@ wizard_page_apply(E_Wizard_Page *pg)
int i; int i;
FILE *f; FILE *f;
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *homedir;
e_user_dir_concat_static(buf, "applications/bar/default");
homedir = e_user_homedir_get();
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/default", homedir);
ecore_file_mkpath(buf); ecore_file_mkpath(buf);
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/default/.order", homedir); e_user_dir_concat_static(buf, "applications/bar/default/.order");
f = fopen(buf, "w"); f = fopen(buf, "w");
if (f) if (f)
{ {

View File

@ -18,13 +18,11 @@ EAPI int
wizard_page_show(E_Wizard_Page *pg) wizard_page_show(E_Wizard_Page *pg)
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *homedir;
if ((e_config_profile_get()) && (strlen(e_config_profile_get()) > 0)) if ((e_config_profile_get()) && (strlen(e_config_profile_get()) > 0))
{ {
// delete profile if (e_user_dir_snprintf(buf, sizeof(buf), "config/%s", e_config_profile_get()) >= sizeof(buf))
homedir = e_user_homedir_get(); return 0;
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s", homedir, e_config_profile_get());
if (ecore_file_is_dir(buf)) ecore_file_recursive_rm(buf); if (ecore_file_is_dir(buf)) ecore_file_recursive_rm(buf);
} }
// load profile as e_config // load profile as e_config
@ -41,30 +39,26 @@ EAPI int
wizard_page_apply(E_Wizard_Page *pg) wizard_page_apply(E_Wizard_Page *pg)
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *homedir;
// setup ~/Desktop and ~/.e/e/fileman/favorites and // setup ~/Desktop and ~/.e/e/fileman/favorites and
// ~/.e/e/applications/bar/default, maybe ~/.e/e/applications/startup/.order // ~/.e/e/applications/bar/default, maybe ~/.e/e/applications/startup/.order
homedir = e_user_homedir_get();
// FIXME: should become a wizard page on its own // FIXME: should become a wizard page on its own
// setup fileman favorites // setup fileman favorites
snprintf(buf, sizeof(buf), snprintf(buf, sizeof(buf),
"gzip -d -c < %s/data/other/efm_favorites.tar.gz | " "gzip -d -c < %s/data/other/efm_favorites.tar.gz | "
"(cd %s/.e/e/ ; tar -xkf -)", "(cd %s/.e/e/ ; tar -xkf -)",
e_prefix_data_get(), homedir); e_prefix_data_get(), e_user_homedir_get());
system(buf); system(buf);
// FIXME: efm favorites linked to desktop should be an option in another // FIXME: efm favorites linked to desktop should be an option in another
// wizard page // wizard page
// ~/Desktop // ~/Desktop
snprintf(buf, sizeof(buf), "%s/Desktop", homedir); e_user_homedir_concat_static(buf, "Desktop");
ecore_file_mkpath(buf); ecore_file_mkpath(buf);
snprintf(buf, sizeof(buf), "%s/Desktop/home.desktop", homedir); e_user_homedir_concat_static(buf, "Desktop/home.desktop");
ecore_file_symlink("../.e/e/fileman/favorites/home.desktop", buf); ecore_file_symlink("../.e/e/fileman/favorites/home.desktop", buf);
snprintf(buf, sizeof(buf), "%s/Desktop/root.desktop", homedir); e_user_homedir_concat_static(buf, "Desktop/root.desktop");
ecore_file_symlink("../.e/e/fileman/favorites/root.desktop", buf); ecore_file_symlink("../.e/e/fileman/favorites/root.desktop", buf);
snprintf(buf, sizeof(buf), "%s/Desktop/tmp.desktop", homedir); e_user_homedir_concat_static(buf, "Desktop/tmp.desktop");
ecore_file_symlink("../.e/e/fileman/favorites/tmp.desktop", buf); ecore_file_symlink("../.e/e/fileman/favorites/tmp.desktop", buf);
// save the config now everyone has modified it // save the config now everyone has modified it