elementary: use portable way to get tmp and home environment.

This commit is contained in:
Cedric BAIL 2015-05-14 21:26:44 +02:00
parent b371af1d25
commit b4da061934
5 changed files with 9 additions and 30 deletions

View File

@ -518,9 +518,6 @@ test_fileselector(void *data EINA_UNUSED,
{
Evas_Object *win, *fs, *box, *vbox, *sep;
char * home_env;
#ifdef _WIN32
char win_home_env[PATH_MAX];
#endif
/* Set the locale according to the system pref.
* If you don't do so the file selector will order the files list in
@ -552,14 +549,7 @@ test_fileselector(void *data EINA_UNUSED,
/* make the file list a tree with dir expandable in place */
elm_fileselector_expandable_set(fs, EINA_FALSE);
/* start the fileselector in the home dir */
home_env = getenv("HOME");
#ifdef _WIN32
if (!home_env)
{
snprintf(win_home_env, sizeof(win_home_env), "%s%s", getenv("HOMEDRIVE"), getenv("HOMEPATH"));
home_env = strdup(win_home_env);
}
#endif
home_env = eina_environment_home_get();
elm_fileselector_path_set(fs, home_env);
/* provides suggested name (just for showing) */

View File

@ -547,7 +547,7 @@ _track_add(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSE
fs = elm_fileselector_add(fs_win);
elm_fileselector_is_save_set(fs, EINA_TRUE);
elm_fileselector_expandable_set(fs, EINA_FALSE);
path = getenv("HOME");
path = eina_environment_home_get();
//if "HOME" is not available, set current dir. path
if (!path)
path = ".";

View File

@ -92,21 +92,11 @@ _fill_list(Evas_Object *obj, Elm_Genlist_Item_Class *itc)
Eina_List *l;
char *real;
char *home_env = NULL;
#ifdef _WIN32
char win_home_env[PATH_MAX];
#endif
unsigned int x = 0;
if (!dirs)
{
home_env = getenv("HOME");
#ifdef _WIN32
if(!home_env)
{
snprintf(win_home_env, sizeof(win_home_env), "%s%s", getenv("HOMEDRIVE"), getenv("HOMEPATH"));
home_env = strdup(win_home_env);
}
#endif
home_env = eina_environment_home_get();
if (!home_env) return;
if (!(d = opendir(home_env))) return;
while ((de = readdir(d)) && (x < LIST_ITEM_MAX))

View File

@ -722,7 +722,7 @@ _elm_config_user_dir_snprintf(char *dst,
else
#endif
{
home = getenv("HOME");
home = eina_environment_home_get();
if (!home) home = "/";
#ifdef DOXDG
user_dir_len = eina_str_join_len

View File

@ -66,7 +66,7 @@ _elm_theme_file_item_add(Elm_Theme_Files *files, const char *item, Eina_Bool pre
Eina_File *f = NULL;
const char *home;
home = getenv("HOME") ? getenv("HOME") : "";
home = eina_environment_home_get();
buf = eina_strbuf_new();
if ((item[0] == '/') ||
@ -682,7 +682,7 @@ elm_theme_list_item_path_get(const char *f, Eina_Bool *in_search_path)
if (!home)
{
home = getenv("HOME");
home = eina_environment_home_get();
if (!home) home = "";
}
@ -761,7 +761,7 @@ elm_theme_name_available_list_new(void)
if (!home)
{
home = getenv("HOME");
home = eina_environment_home_get();
if (!home) home = "";
}
@ -937,12 +937,11 @@ elm_theme_user_dir_get(void)
{
static char *path = NULL;
char buf[PATH_MAX];
const char *home;
if (path) return path;
char *home = getenv("HOME");
if (!home) home = "";
home = eina_environment_home_get();
snprintf(buf, sizeof(buf), "%s/"ELEMENTARY_BASE_DIR"/themes", home);
path = strdup(buf);