forked from enlightenment/efl
vpath usage - simplify to bare minimum to make gustavo happy
since these are only local path resolves, the do and wait are technically not needed. also remove any other tmp strings and use the vpath string resolving feature to avoid printfs/strjoins/cats etc. etc. as well. also remember to remove old name string from evas shm code - it worked for me. i guess i was lucky and it happened to be NULL thus free was fine.
This commit is contained in:
parent
7cc8f085b8
commit
0356b1eb5e
|
@ -311,9 +311,8 @@ efreet_dirs_init(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* xdg_runtime_dir */
|
/* xdg_runtime_dir */
|
||||||
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, "(:run:)/");
|
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS,
|
||||||
efl_vpath_file_do(file_obj);
|
"(:run:)/");
|
||||||
efl_vpath_file_wait(file_obj);
|
|
||||||
xdg_runtime_dir = eina_stringshare_add(efl_vpath_file_result_get(file_obj));
|
xdg_runtime_dir = eina_stringshare_add(efl_vpath_file_result_get(file_obj));
|
||||||
efl_del(file_obj);
|
efl_del(file_obj);
|
||||||
|
|
||||||
|
|
|
@ -615,9 +615,6 @@ _elm_config_user_dir_snprintf(char *dst,
|
||||||
va_list ap;
|
va_list ap;
|
||||||
Efl_Vpath_File *file_obj;
|
Efl_Vpath_File *file_obj;
|
||||||
static int use_xdg_config = -1;
|
static int use_xdg_config = -1;
|
||||||
const char elmdir[] = "elementary";
|
|
||||||
const char elmdotdir[] = ".elementary";
|
|
||||||
const char *path = NULL;
|
|
||||||
|
|
||||||
if (use_xdg_config == -1)
|
if (use_xdg_config == -1)
|
||||||
{
|
{
|
||||||
|
@ -625,26 +622,15 @@ _elm_config_user_dir_snprintf(char *dst,
|
||||||
else use_xdg_config = 0;
|
else use_xdg_config = 0;
|
||||||
}
|
}
|
||||||
if (use_xdg_config)
|
if (use_xdg_config)
|
||||||
{
|
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS,
|
||||||
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, "(:config:)/");
|
"(:config:)/elementary");
|
||||||
efl_vpath_file_do(file_obj);
|
|
||||||
efl_vpath_file_wait(file_obj);
|
|
||||||
path = efl_vpath_file_result_get(file_obj);
|
|
||||||
user_dir_len = eina_str_join_len
|
|
||||||
(dst, size, '/', path, strlen(path) - 1, elmdir, sizeof(elmdir) - 1);
|
|
||||||
efl_del(file_obj);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS,
|
||||||
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, "(:home:)/");
|
"(:home:)/.elementary");
|
||||||
efl_vpath_file_do(file_obj);
|
eina_strlcpy(dst, efl_vpath_file_result_get(file_obj), size);
|
||||||
efl_vpath_file_wait(file_obj);
|
|
||||||
path = efl_vpath_file_result_get(file_obj);
|
|
||||||
user_dir_len = eina_str_join_len
|
|
||||||
(dst, size, '/', path, strlen(path) - 1, elmdotdir, sizeof(elmdotdir) - 1);
|
|
||||||
efl_del(file_obj);
|
efl_del(file_obj);
|
||||||
}
|
|
||||||
|
|
||||||
|
user_dir_len = strlen(dst);
|
||||||
off = user_dir_len + 1;
|
off = user_dir_len + 1;
|
||||||
if (off >= size) return off;
|
if (off >= size) return off;
|
||||||
dst[user_dir_len] = '/';
|
dst[user_dir_len] = '/';
|
||||||
|
|
|
@ -60,21 +60,16 @@ _keyboard_modifiers_update(Elput_Keyboard *kbd, Elput_Seat *seat)
|
||||||
static int
|
static int
|
||||||
_keyboard_fd_get(off_t size)
|
_keyboard_fd_get(off_t size)
|
||||||
{
|
{
|
||||||
const char *path;
|
|
||||||
Eina_Tmpstr *fullname;
|
Eina_Tmpstr *fullname;
|
||||||
long flags;
|
long flags;
|
||||||
int fd = 0;
|
int fd = 0;
|
||||||
char tmp[PATH_MAX];
|
|
||||||
Efl_Vpath_File *file_obj;
|
Efl_Vpath_File *file_obj;
|
||||||
|
|
||||||
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, "(:run:)/");
|
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS,
|
||||||
efl_vpath_file_do(file_obj);
|
"(:run:)/elput-keymap-XXXXXX");
|
||||||
efl_vpath_file_wait(file_obj);
|
fd = eina_file_mkstemp(efl_vpath_file_result_get(file_obj), &fullname);
|
||||||
path = efl_vpath_file_result_get(file_obj);
|
|
||||||
snprintf(tmp, sizeof(tmp), "%s/elput-keymap-XXXXXX", path);
|
|
||||||
efl_del(file_obj);
|
efl_del(file_obj);
|
||||||
|
|
||||||
fd = eina_file_mkstemp(tmp, &fullname);
|
|
||||||
if (fd < 0) return -1;
|
if (fd < 0) return -1;
|
||||||
|
|
||||||
flags = fcntl(fd, F_GETFD);
|
flags = fcntl(fd, F_GETFD);
|
||||||
|
|
|
@ -54,8 +54,6 @@ _ecore_buffer_shm_buffer_alloc(Ecore_Buffer_Module_Data bmdata, int width, int h
|
||||||
{
|
{
|
||||||
Ecore_Buffer_Shm_Data* b;
|
Ecore_Buffer_Shm_Data* b;
|
||||||
char *name;
|
char *name;
|
||||||
static const char tmp[] = "ecore-buffer-shared-XXXXXX";
|
|
||||||
const char *path;
|
|
||||||
int fd, size, page_size;
|
int fd, size, page_size;
|
||||||
Efl_Vpath_File *file_obj;
|
Efl_Vpath_File *file_obj;
|
||||||
|
|
||||||
|
@ -70,16 +68,11 @@ _ecore_buffer_shm_buffer_alloc(Ecore_Buffer_Module_Data bmdata, int width, int h
|
||||||
b->size = page_size * (((b->stride * b->h) + (page_size - 1)) / page_size);
|
b->size = page_size * (((b->stride * b->h) + (page_size - 1)) / page_size);
|
||||||
b->am_owner = EINA_TRUE;
|
b->am_owner = EINA_TRUE;
|
||||||
|
|
||||||
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, "(:run:)/");
|
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS,
|
||||||
efl_vpath_file_do(file_obj);
|
"(:run:)/ecore-buffer-shared-XXXXXX");
|
||||||
efl_vpath_file_wait(file_obj);
|
name = strdup(efl_vpath_file_result_get(file_obj));
|
||||||
path = efl_vpath_file_result_get(file_obj);
|
|
||||||
size = strlen(path) + sizeof(tmp);
|
|
||||||
name = malloc(size);
|
|
||||||
if (!name) goto err;
|
|
||||||
strcpy(name, path);
|
|
||||||
strcat(name, tmp);
|
|
||||||
efl_del(file_obj);
|
efl_del(file_obj);
|
||||||
|
if (!name) goto err;
|
||||||
|
|
||||||
fd = mkostemp(name, O_CLOEXEC);
|
fd = mkostemp(name, O_CLOEXEC);
|
||||||
if (fd < 0) goto err_fd;
|
if (fd < 0) goto err_fd;
|
||||||
|
|
|
@ -82,9 +82,6 @@ static struct wl_shm_pool *
|
||||||
_shm_pool_make(struct wl_shm *shm, int size, void **data)
|
_shm_pool_make(struct wl_shm *shm, int size, void **data)
|
||||||
{
|
{
|
||||||
struct wl_shm_pool *pool;
|
struct wl_shm_pool *pool;
|
||||||
static const char tmp[] = "evas-wayland_shm-XXXXXX";
|
|
||||||
const char *path;
|
|
||||||
char *name;
|
|
||||||
int fd = 0;
|
int fd = 0;
|
||||||
Eina_Tmpstr *fullname;
|
Eina_Tmpstr *fullname;
|
||||||
Efl_Vpath_File *file_obj;
|
Efl_Vpath_File *file_obj;
|
||||||
|
@ -95,26 +92,20 @@ _shm_pool_make(struct wl_shm *shm, int size, void **data)
|
||||||
if (!shm) return NULL;
|
if (!shm) return NULL;
|
||||||
|
|
||||||
/* create tmp file name */
|
/* create tmp file name */
|
||||||
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, "(:run:)/");
|
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS,
|
||||||
efl_vpath_file_do(file_obj);
|
"(:run:)/evas-wayland_shm-XXXXXX");
|
||||||
efl_vpath_file_wait(file_obj);
|
fd = eina_file_mkstemp(efl_vpath_file_result_get(file_obj), &fullname);
|
||||||
path = efl_vpath_file_result_get(file_obj);
|
efl_del(file_obj);
|
||||||
if ((name = malloc(strlen(path) + sizeof(tmp)))) strcpy(name, path);
|
|
||||||
if (!name) return NULL;
|
|
||||||
strcat(name, tmp);
|
|
||||||
|
|
||||||
fd = eina_file_mkstemp(name, &fullname);
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
/* try to create tmp file */
|
/* try to create tmp file */
|
||||||
/* if ((fd = mkstemp(name)) < 0) */
|
/* if ((fd = mkstemp(name)) < 0) */
|
||||||
{
|
{
|
||||||
ERR("Could not create temporary file: %m");
|
ERR("Could not create temporary file: %m");
|
||||||
free(name);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink(fullname);
|
unlink(fullname);
|
||||||
free(name);
|
|
||||||
eina_tmpstr_del(fullname);
|
eina_tmpstr_del(fullname);
|
||||||
|
|
||||||
/* try to truncate file to size */
|
/* try to truncate file to size */
|
||||||
|
|
Loading…
Reference in New Issue