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; Evas_Object *win, *fs, *box, *vbox, *sep;
char * home_env; char * home_env;
#ifdef _WIN32
char win_home_env[PATH_MAX];
#endif
/* Set the locale according to the system pref. /* Set the locale according to the system pref.
* If you don't do so the file selector will order the files list in * 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 */ /* make the file list a tree with dir expandable in place */
elm_fileselector_expandable_set(fs, EINA_FALSE); elm_fileselector_expandable_set(fs, EINA_FALSE);
/* start the fileselector in the home dir */ /* start the fileselector in the home dir */
home_env = getenv("HOME"); home_env = eina_environment_home_get();
#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
elm_fileselector_path_set(fs, home_env); elm_fileselector_path_set(fs, home_env);
/* provides suggested name (just for showing) */ /* 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); fs = elm_fileselector_add(fs_win);
elm_fileselector_is_save_set(fs, EINA_TRUE); elm_fileselector_is_save_set(fs, EINA_TRUE);
elm_fileselector_expandable_set(fs, EINA_FALSE); 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 "HOME" is not available, set current dir. path
if (!path) if (!path)
path = "."; path = ".";

View File

@ -92,21 +92,11 @@ _fill_list(Evas_Object *obj, Elm_Genlist_Item_Class *itc)
Eina_List *l; Eina_List *l;
char *real; char *real;
char *home_env = NULL; char *home_env = NULL;
#ifdef _WIN32
char win_home_env[PATH_MAX];
#endif
unsigned int x = 0; unsigned int x = 0;
if (!dirs) if (!dirs)
{ {
home_env = getenv("HOME"); home_env = eina_environment_home_get();
#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
if (!home_env) return; if (!home_env) return;
if (!(d = opendir(home_env))) return; if (!(d = opendir(home_env))) return;
while ((de = readdir(d)) && (x < LIST_ITEM_MAX)) while ((de = readdir(d)) && (x < LIST_ITEM_MAX))

View File

@ -722,7 +722,7 @@ _elm_config_user_dir_snprintf(char *dst,
else else
#endif #endif
{ {
home = getenv("HOME"); home = eina_environment_home_get();
if (!home) home = "/"; if (!home) home = "/";
#ifdef DOXDG #ifdef DOXDG
user_dir_len = eina_str_join_len 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; Eina_File *f = NULL;
const char *home; const char *home;
home = getenv("HOME") ? getenv("HOME") : ""; home = eina_environment_home_get();
buf = eina_strbuf_new(); buf = eina_strbuf_new();
if ((item[0] == '/') || if ((item[0] == '/') ||
@ -682,7 +682,7 @@ elm_theme_list_item_path_get(const char *f, Eina_Bool *in_search_path)
if (!home) if (!home)
{ {
home = getenv("HOME"); home = eina_environment_home_get();
if (!home) home = ""; if (!home) home = "";
} }
@ -761,7 +761,7 @@ elm_theme_name_available_list_new(void)
if (!home) if (!home)
{ {
home = getenv("HOME"); home = eina_environment_home_get();
if (!home) home = ""; if (!home) home = "";
} }
@ -937,12 +937,11 @@ elm_theme_user_dir_get(void)
{ {
static char *path = NULL; static char *path = NULL;
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *home;
if (path) return path; if (path) return path;
char *home = getenv("HOME"); home = eina_environment_home_get();
if (!home) home = "";
snprintf(buf, sizeof(buf), "%s/"ELEMENTARY_BASE_DIR"/themes", home); snprintf(buf, sizeof(buf), "%s/"ELEMENTARY_BASE_DIR"/themes", home);
path = strdup(buf); path = strdup(buf);