Ephoto: Fix use of stat/lstat, use eina_environment to get HOME and tmp dirs.
This commit is contained in:
parent
751e08acc7
commit
ef805cefa9
|
@ -19,7 +19,7 @@ _config_save_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
if (!strcmp(text, _("Root Directory")))
|
||||
path = "/";
|
||||
else if (!strcmp(text, _("Home Directory")))
|
||||
path = getenv("HOME");
|
||||
path = eina_environment_home_get();
|
||||
else if (!strcmp(text, _("Last Open Directory")))
|
||||
path = "Last";
|
||||
else
|
||||
|
@ -778,7 +778,7 @@ ephoto_config_init(Ephoto *ephoto)
|
|||
ephoto->config->window_height = 500*elm_config_scale_get();
|
||||
ephoto->config->fsel_hide = 0;
|
||||
ephoto->config->lpane_size = .15;
|
||||
ephoto->config->open = eina_stringshare_add(getenv("HOME"));
|
||||
ephoto->config->open = eina_stringshare_add(eina_environment_home_get());
|
||||
ephoto->config->prompts = 1;
|
||||
ephoto->config->drop = 0;
|
||||
ephoto->config->movess = 1;
|
||||
|
|
|
@ -473,7 +473,7 @@ _dir_go_trash(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
|
||||
eina_stringshare_replace(&db->back_directory,
|
||||
db->ephoto->config->directory);
|
||||
snprintf(path, PATH_MAX, "%s/.config/ephoto/trash", getenv("HOME"));
|
||||
snprintf(path, PATH_MAX, "%s/.config/ephoto/trash", eina_environment_home_get());
|
||||
if (!ecore_file_exists(path))
|
||||
ecore_file_mkpath(path);
|
||||
db->thumbs_only = 0;
|
||||
|
@ -607,7 +607,7 @@ _fsel_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
|
|||
if (info->button != 3)
|
||||
return;
|
||||
|
||||
snprintf(trash, PATH_MAX, "%s/.config/ephoto/trash", getenv("HOME"));
|
||||
snprintf(trash, PATH_MAX, "%s/.config/ephoto/trash", eina_environment_home_get());
|
||||
|
||||
if (item)
|
||||
elm_genlist_item_selected_set(item, EINA_TRUE);
|
||||
|
|
|
@ -728,7 +728,7 @@ _delete_thread_cb(void *data, Ecore_Thread *et EINA_UNUSED)
|
|||
const char *file;
|
||||
char destination[PATH_MAX];
|
||||
|
||||
snprintf(destination, PATH_MAX, "%s/.config/ephoto/trash", getenv("HOME"));
|
||||
snprintf(destination, PATH_MAX, "%s/.config/ephoto/trash", eina_environment_home_get());
|
||||
if (!ecore_file_exists(destination))
|
||||
ecore_file_mkpath(destination);
|
||||
|
||||
|
@ -743,11 +743,10 @@ _delete_thread_cb(void *data, Ecore_Thread *et EINA_UNUSED)
|
|||
char dest[PATH_MAX], fp[PATH_MAX], extra[PATH_MAX];
|
||||
int ret;
|
||||
struct stat s;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (stat(file, &s))
|
||||
if (stat(file, &s) == 0)
|
||||
#else
|
||||
if (lstat(file, &s))
|
||||
if (lstat(file, &s) == 0)
|
||||
#endif
|
||||
{
|
||||
if (S_ISLNK(s.st_mode))
|
||||
|
@ -808,7 +807,7 @@ _delete_dir_thread_cb(void *data, Ecore_Thread *et EINA_UNUSED)
|
|||
const char *dir = eina_list_data_get(ephoto->file_pos);
|
||||
char destination[PATH_MAX];
|
||||
|
||||
snprintf(destination, PATH_MAX, "%s/.config/ephoto/trash", getenv("HOME"));
|
||||
snprintf(destination, PATH_MAX, "%s/.config/ephoto/trash", eina_environment_home_get());
|
||||
|
||||
if (!ecore_file_exists(destination))
|
||||
ecore_file_mkpath(destination);
|
||||
|
@ -868,7 +867,7 @@ _empty_trash_thread_cb(void *data, Ecore_Thread *th EINA_UNUSED)
|
|||
const char *file;
|
||||
char trash[PATH_MAX];
|
||||
|
||||
snprintf(trash, PATH_MAX, "%s/.config/ephoto/trash", getenv("HOME"));
|
||||
snprintf(trash, PATH_MAX, "%s/.config/ephoto/trash", eina_environment_home_get());
|
||||
|
||||
if (!ephoto->file_pos)
|
||||
ephoto->file_pos = eina_list_nth(ephoto->file_pos, 0);
|
||||
|
|
|
@ -18,42 +18,20 @@ int
|
|||
e_ipc_init(void)
|
||||
{
|
||||
char buf[4096], buf3[4096];
|
||||
const char *tmp, *user, *base;
|
||||
const char *tmp, *user, *base = NULL;
|
||||
int pid, trynum = 0, id1 = 0;
|
||||
|
||||
tmp = eina_environment_tmp_get();
|
||||
if (!tmp) tmp = "/tmp";
|
||||
base = tmp;
|
||||
|
||||
tmp = getenv("XDG_RUNTIME_DIR");
|
||||
if (tmp)
|
||||
{
|
||||
if (ecore_file_exists(tmp))
|
||||
{
|
||||
if (ecore_file_is_dir(tmp) && ecore_file_can_write(tmp))
|
||||
base = tmp;
|
||||
else
|
||||
ERR("XDG_RUNTIME_DIR of '%s' failed permissions check", tmp);
|
||||
}
|
||||
else
|
||||
ERR("XDG_RUNTIME_DIR of '%s' cannot be accessed", tmp);
|
||||
}
|
||||
|
||||
tmp = getenv("SD_USER_SOCKETS_DIR");
|
||||
if (tmp)
|
||||
{
|
||||
if (ecore_file_exists(tmp))
|
||||
{
|
||||
if (ecore_file_is_dir(tmp) && ecore_file_can_write(tmp))
|
||||
base = tmp;
|
||||
else
|
||||
ERR("SD_USER_SOCKETS_DIR of '%s' failed permissions check", tmp);
|
||||
}
|
||||
else
|
||||
ERR("SD_USER_SOCKETS_DIR of '%s' cannot be accessed", tmp);
|
||||
}
|
||||
if (ecore_file_is_dir(tmp) && ecore_file_can_write(tmp))
|
||||
base = tmp;
|
||||
else
|
||||
ERR("Temp dir could not be accessed");
|
||||
|
||||
#ifdef _WIN32
|
||||
user = getenv("USERNAME");
|
||||
#else
|
||||
user = getenv("USER");
|
||||
#endif
|
||||
|
||||
setenv("EPHOTO_IPC_SOCKET", "", 1);
|
||||
|
||||
|
|
|
@ -561,7 +561,7 @@ ephoto_window_add(const char *path)
|
|||
if (getcwd(buf, sizeof(buf)))
|
||||
path = buf;
|
||||
else
|
||||
path = getenv("HOME");
|
||||
path = eina_environment_home_get();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ ephoto_scale_add(Ephoto *ephoto, Evas_Object *main, Evas_Object *parent,
|
|||
es->parent = parent;
|
||||
es->image = image;
|
||||
|
||||
snprintf(buf, PATH_MAX, "%s/.config/ephoto/temp.%s", getenv("HOME"),
|
||||
snprintf(buf, PATH_MAX, "%s/.config/ephoto/temp.%s", eina_environment_home_get(),
|
||||
strrchr(file, '.')+1);
|
||||
es->tmp_file = eina_stringshare_add(buf);
|
||||
if (ecore_file_exists(es->tmp_file))
|
||||
|
|
|
@ -2084,7 +2084,7 @@ _ephoto_main_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
if (sb->edit_main)
|
||||
evas_object_del(sb->edit_main);
|
||||
sb->edit_main = NULL;
|
||||
snprintf(tmp_path, PATH_MAX, "%s/.config/ephoto/", getenv("HOME"));
|
||||
snprintf(tmp_path, PATH_MAX, "%s/.config/ephoto/", eina_environment_home_get());
|
||||
tmps = eina_file_stat_ls(tmp_path);
|
||||
EINA_ITERATOR_FOREACH(tmps, info)
|
||||
{
|
||||
|
|
|
@ -945,7 +945,7 @@ _grid_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
|
|||
return;
|
||||
}
|
||||
|
||||
snprintf(trash, PATH_MAX, "%s/.config/ephoto/trash", getenv("HOME"));
|
||||
snprintf(trash, PATH_MAX, "%s/.config/ephoto/trash", eina_environment_home_get());
|
||||
|
||||
if (item)
|
||||
{
|
||||
|
@ -1724,7 +1724,7 @@ _ephoto_main_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNU
|
|||
char *trash;
|
||||
|
||||
snprintf(path, PATH_MAX, "%s/.config/ephoto/trash",
|
||||
getenv("HOME"));
|
||||
eina_environment_home_get());
|
||||
trash = strdup(path);
|
||||
if ((strlen(trash)) == (strlen(tb->ephoto->config->directory)))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue