summaryrefslogtreecommitdiff
path: root/src/bin/efreet/efreetd_cache.c
diff options
context:
space:
mode:
authorAl Poole <netstar@gmail.com>2017-05-10 12:26:04 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-05-10 12:26:08 -0700
commit169a08c03a6a7270e185bda85d4ab9afd9063c8e (patch)
tree3cdc3866288e47af9657e443e08db3b43fd3a2db /src/bin/efreet/efreetd_cache.c
parentc6212e6e67af4e48e90fe9ddea64774e82b908d8 (diff)
efreetd: BSD optimizations.
Summary: Related to ticket T5475. Reviewers: raster, cedric Subscribers: jpeg, cedric, raster Differential Revision: https://phab.enlightenment.org/D4865 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to '')
-rw-r--r--src/bin/efreet/efreetd_cache.c196
1 files changed, 118 insertions, 78 deletions
diff --git a/src/bin/efreet/efreetd_cache.c b/src/bin/efreet/efreetd_cache.c
index 7f3dc07e98..58fb520ba3 100644
--- a/src/bin/efreet/efreetd_cache.c
+++ b/src/bin/efreet/efreetd_cache.c
@@ -89,7 +89,6 @@ static void
89subdir_cache_dir_free(Subdir_Cache_Dir *cd) 89subdir_cache_dir_free(Subdir_Cache_Dir *cd)
90{ 90{
91 unsigned int i; 91 unsigned int i;
92
93 if (!cd) return; 92 if (!cd) return;
94 if (cd->dirs) 93 if (cd->dirs)
95 { 94 {
@@ -112,9 +111,10 @@ subdir_cache_hash_add(void *hash, const char *key, void *data)
112static void 111static void
113subdir_cache_init(void) 112subdir_cache_init(void)
114{ 113{
115 char buf[PATH_MAX];
116 Eet_Data_Descriptor_Class eddc; 114 Eet_Data_Descriptor_Class eddc;
117 Eet_File *ef; 115 Eet_File *ef;
116 Eina_Strbuf *buf = eina_strbuf_new();
117 if (!buf) return;
118 118
119 // set up data codecs for subdirs in memory 119 // set up data codecs for subdirs in memory
120 eet_eina_stream_data_descriptor_class_set(&eddc, sizeof(Subdir_Cache_Dir), "D", sizeof(Subdir_Cache_Dir)); 120 eet_eina_stream_data_descriptor_class_set(&eddc, sizeof(Subdir_Cache_Dir), "D", sizeof(Subdir_Cache_Dir));
@@ -136,14 +136,16 @@ subdir_cache_init(void)
136 EET_DATA_DESCRIPTOR_ADD_HASH(subdir_edd, Subdir_Cache, "dirs", dirs, subdir_dir_edd); 136 EET_DATA_DESCRIPTOR_ADD_HASH(subdir_edd, Subdir_Cache, "dirs", dirs, subdir_dir_edd);
137 137
138 // load subdirs from the cache file 138 // load subdirs from the cache file
139 snprintf(buf, sizeof(buf), "%s/efreet/subdirs_%s.eet", 139 eina_strbuf_append_printf(buf, "%s/efreet/subdirs_%s.eet",
140 efreet_cache_home_get(), efreet_hostname_get()); 140 efreet_cache_home_get(), efreet_hostname_get());
141 ef = eet_open(buf, EET_FILE_MODE_READ); 141 ef = eet_open(eina_strbuf_string_get(buf), EET_FILE_MODE_READ);
142 if (ef) 142 if (ef)
143 { 143 {
144 subdir_cache = eet_data_read(ef, subdir_edd, "subdirs"); 144 subdir_cache = eet_data_read(ef, subdir_edd, "subdirs");
145 eet_close(ef); 145 eet_close(ef);
146 } 146 }
147 eina_strbuf_free(buf);
148
147 // if we don't have a decoded subdir cache - allocate one 149 // if we don't have a decoded subdir cache - allocate one
148 if (!subdir_cache) subdir_cache = calloc(1, sizeof(Subdir_Cache)); 150 if (!subdir_cache) subdir_cache = calloc(1, sizeof(Subdir_Cache));
149 if (!subdir_cache) 151 if (!subdir_cache)
@@ -176,22 +178,28 @@ subdir_cache_shutdown(void)
176static void 178static void
177subdir_cache_save(void) 179subdir_cache_save(void)
178{ 180{
179 char buf[PATH_MAX], buf2[PATH_MAX]; 181 Eina_Strbuf *buf;
180 Eet_File *ef; 182 Eet_File *ef;
181 Eina_Tmpstr *tmpstr = NULL; 183 Eina_Tmpstr *tmpstr = NULL;
182 int tmpfd; 184 int tmpfd;
183 185
186 buf = eina_strbuf_new();
187 if (!buf) return;
188
184 // only if subdirs need saving... and we have subdirs. 189 // only if subdirs need saving... and we have subdirs.
185 if (!subdir_need_save) return; 190 if (!subdir_need_save) return;
186 if (!subdir_cache) return; 191 if (!subdir_cache) return;
187 if (!subdir_cache->dirs) return; 192 if (!subdir_cache->dirs) return;
188 193
189 // save to tmp file first 194 // save to tmp file first
190 snprintf(buf2, sizeof(buf2), "%s/efreet/subdirs_%s.eet.XXXXXX.cache", 195 eina_strbuf_append_printf(buf, "%s/efreet/subdirs_%s.eet.XXXXXX.cache",
191 efreet_cache_home_get(), efreet_hostname_get()); 196 efreet_cache_home_get(), efreet_hostname_get());
192 tmpfd = eina_file_mkstemp(buf2, &tmpstr); 197
198 tmpfd = eina_file_mkstemp(eina_strbuf_string_get(buf), &tmpstr);
193 if (tmpfd < 0) return; 199 if (tmpfd < 0) return;
194 200
201 eina_strbuf_reset(buf);
202
195 // write out eet file to tmp file 203 // write out eet file to tmp file
196 ef = eet_open(tmpstr, EET_FILE_MODE_WRITE); 204 ef = eet_open(tmpstr, EET_FILE_MODE_WRITE);
197 eet_data_write(ef, subdir_edd, "subdirs", subdir_cache, EET_COMPRESSION_SUPERFAST); 205 eet_data_write(ef, subdir_edd, "subdirs", subdir_cache, EET_COMPRESSION_SUPERFAST);
@@ -207,16 +215,18 @@ subdir_cache_save(void)
207#endif 215#endif
208 216
209 // atomically rename subdirs file on top from tmp file 217 // atomically rename subdirs file on top from tmp file
210 snprintf(buf, sizeof(buf), "%s/efreet/subdirs_%s.eet", 218 eina_strbuf_append_printf(buf, "%s/efreet/subdirs_%s.eet",
211 efreet_cache_home_get(), efreet_hostname_get()); 219 efreet_cache_home_get(), efreet_hostname_get());
212 if (rename(tmpstr, buf) < 0) 220
221 if (rename(tmpstr, eina_strbuf_string_get(buf)) < 0)
213 { 222 {
214 unlink(tmpstr); 223 unlink(tmpstr);
215 ERR("Can't save subdir cache %s", buf); 224 ERR("Can't save subdir cache %s", eina_strbuf_string_get(buf));
216 } 225 }
217 // we dont need saving anymore - we just did 226 // we dont need saving anymore - we just did
218 subdir_need_save = EINA_FALSE; 227 subdir_need_save = EINA_FALSE;
219 eina_tmpstr_del(tmpstr); 228 eina_tmpstr_del(tmpstr);
229 eina_strbuf_free(buf);
220} 230}
221 231
222static const Subdir_Cache_Dir * 232static const Subdir_Cache_Dir *
@@ -269,6 +279,7 @@ subdir_cache_get(const struct stat *st, const char *path)
269 // go through content finding directories 279 // go through content finding directories
270 it = eina_file_stat_ls(path); 280 it = eina_file_stat_ls(path);
271 if (!it) return cd; 281 if (!it) return cd;
282
272 EINA_ITERATOR_FOREACH(it, info) 283 EINA_ITERATOR_FOREACH(it, info)
273 { 284 {
274 // if ., .. or other "hidden" dot files - ignore 285 // if ., .. or other "hidden" dot files - ignore
@@ -283,6 +294,7 @@ subdir_cache_get(const struct stat *st, const char *path)
283 } 294 }
284 } 295 }
285 eina_iterator_free(it); 296 eina_iterator_free(it);
297
286 // now convert our temporary list into an array of stringshare strings 298 // now convert our temporary list into an array of stringshare strings
287 cd->dirs_count = eina_list_count(files); 299 cd->dirs_count = eina_list_count(files);
288 if (cd->dirs_count > 0) 300 if (cd->dirs_count > 0)
@@ -304,7 +316,8 @@ subdir_cache_get(const struct stat *st, const char *path)
304static Eina_Bool 316static Eina_Bool
305icon_cache_update_cache_cb(void *data EINA_UNUSED) 317icon_cache_update_cache_cb(void *data EINA_UNUSED)
306{ 318{
307 char file[PATH_MAX]; 319 Eina_Strbuf *file = eina_strbuf_new();
320 if (!file) return EINA_FALSE;
308 321
309 icon_cache_timer = NULL; 322 icon_cache_timer = NULL;
310 323
@@ -325,19 +338,18 @@ icon_cache_update_cache_cb(void *data EINA_UNUSED)
325 subdir_cache_save(); 338 subdir_cache_save();
326 339
327 /* TODO: Queue if already running */ 340 /* TODO: Queue if already running */
328 snprintf(file, sizeof(file), 341 eina_strbuf_append_printf(file, "%s/efreet/" MODULE_ARCH "/efreet_icon_cache_create",
329 "%s/efreet/" MODULE_ARCH "/efreet_icon_cache_create", 342 eina_prefix_lib_get(pfx));
330 eina_prefix_lib_get(pfx));
331 if (icon_extra_dirs) 343 if (icon_extra_dirs)
332 { 344 {
333 Eina_List *ll; 345 Eina_List *ll;
334 char *p; 346 char *p;
335 347
336 eina_strlcat(file, " -d", sizeof(file)); 348 eina_strbuf_append(file, " -d");
337 EINA_LIST_FOREACH(icon_extra_dirs, ll, p) 349 EINA_LIST_FOREACH(icon_extra_dirs, ll, p)
338 { 350 {
339 eina_strlcat(file, " ", sizeof(file)); 351 eina_strbuf_append(file, " ");
340 eina_strlcat(file, p, sizeof(file)); 352 eina_strbuf_append(file, p);
341 } 353 }
342 } 354 }
343 if (icon_exts) 355 if (icon_exts)
@@ -345,18 +357,22 @@ icon_cache_update_cache_cb(void *data EINA_UNUSED)
345 Eina_List *ll; 357 Eina_List *ll;
346 char *p; 358 char *p;
347 359
348 eina_strlcat(file, " -e", sizeof(file)); 360 eina_strbuf_append(file, " -e");
349 EINA_LIST_FOREACH(icon_exts, ll, p) 361 EINA_LIST_FOREACH(icon_exts, ll, p)
350 { 362 {
351 eina_strlcat(file, " ", sizeof(file)); 363 eina_strbuf_append(file, " ");
352 eina_strlcat(file, p, sizeof(file)); 364 eina_strbuf_append(file, p);
353 } 365 }
354 } 366 }
355 if (icon_flush) 367 if (icon_flush)
356 eina_strlcat(file, " -f", sizeof(file)); 368 eina_strbuf_append(file, " -f");
357 icon_flush = EINA_FALSE; 369 icon_flush = EINA_FALSE;
358 icon_cache_exe = 370 icon_cache_exe =
359 ecore_exe_pipe_run(file, ECORE_EXE_PIPE_READ|ECORE_EXE_PIPE_READ_LINE_BUFFERED, NULL); 371 ecore_exe_pipe_run(eina_strbuf_string_get(file), ECORE_EXE_PIPE_READ |
372 ECORE_EXE_PIPE_READ_LINE_BUFFERED,
373 NULL);
374
375 eina_strbuf_free(file);
360 376
361 return ECORE_CALLBACK_CANCEL; 377 return ECORE_CALLBACK_CANCEL;
362} 378}
@@ -364,7 +380,7 @@ icon_cache_update_cache_cb(void *data EINA_UNUSED)
364static Eina_Bool 380static Eina_Bool
365desktop_cache_update_cache_cb(void *data EINA_UNUSED) 381desktop_cache_update_cache_cb(void *data EINA_UNUSED)
366{ 382{
367 char file[PATH_MAX]; 383 Eina_Strbuf *file = eina_strbuf_new();
368 384
369 desktop_cache_timer = NULL; 385 desktop_cache_timer = NULL;
370 386
@@ -383,24 +399,27 @@ desktop_cache_update_cache_cb(void *data EINA_UNUSED)
383 desktop_changes_listen(); 399 desktop_changes_listen();
384 subdir_cache_save(); 400 subdir_cache_save();
385 401
386 snprintf(file, sizeof(file), 402 eina_strbuf_append_printf(file, "%s/efreet/" MODULE_ARCH "/efreet_desktop_cache_create",
387 "%s/efreet/" MODULE_ARCH "/efreet_desktop_cache_create", 403 eina_prefix_lib_get(pfx));
388 eina_prefix_lib_get(pfx));
389 if (desktop_extra_dirs) 404 if (desktop_extra_dirs)
390 { 405 {
391 Eina_List *ll; 406 Eina_List *ll;
392 const char *str; 407 const char *str;
393 408
394 eina_strlcat(file, " -d", sizeof(file)); 409 eina_strbuf_append(file, " -d");
395 EINA_LIST_FOREACH(desktop_extra_dirs, ll, str) 410 EINA_LIST_FOREACH(desktop_extra_dirs, ll, str)
396 { 411 {
397 eina_strlcat(file, " ", sizeof(file)); 412 eina_strbuf_append(file, " ");
398 eina_strlcat(file, str, sizeof(file)); 413 eina_strbuf_append(file, str);
399 } 414 }
400 } 415 }
401 INF("Run desktop cache creation: %s", file); 416 INF("Run desktop cache creation: %s", eina_strbuf_string_get(file));
402 desktop_cache_exe = ecore_exe_pipe_run 417 desktop_cache_exe = ecore_exe_pipe_run
403 (file, ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_READ_LINE_BUFFERED, NULL); 418 (eina_strbuf_string_get(file), ECORE_EXE_PIPE_READ |
419 ECORE_EXE_PIPE_READ_LINE_BUFFERED,
420 NULL);
421
422 eina_strbuf_free(file);
404 423
405 return ECORE_CALLBACK_CANCEL; 424 return ECORE_CALLBACK_CANCEL;
406} 425}
@@ -536,14 +555,15 @@ _check_recurse_monitor_sanity(Eina_Inarray *stack, const char *path, unsigned in
536static void 555static void
537icon_changes_listen_recursive(Eina_Inarray *stack, const char *path, Eina_Bool base) 556icon_changes_listen_recursive(Eina_Inarray *stack, const char *path, Eina_Bool base)
538{ 557{
539 struct stat st; 558 struct stat *st = eina_mempool_malloc(efreetd_mp_stat, sizeof(struct stat));
559 if (!st) return;
540 560
541 if (stat(path, &st) == -1) return; 561 if (stat(path, st) == -1) return;
542 if (eina_inarray_search(stack, &st, stat_cmp) >= 0) return; 562 if (eina_inarray_search(stack, st, stat_cmp) >= 0) return;
543 if (!_check_recurse_monitor_sanity(stack, path, 10)) return; 563 if (!_check_recurse_monitor_sanity(stack, path, 10)) return;
544 eina_inarray_push(stack, &st); 564 eina_inarray_push(stack, st);
545 565
546 if ((!S_ISDIR(st.st_mode)) && (base)) 566 if ((!S_ISDIR(st->st_mode)) && (base))
547 { 567 {
548 // XXX: if it doesn't exist... walk the parent dirs back down 568 // XXX: if it doesn't exist... walk the parent dirs back down
549 // to this path until we find one that doesn't exist, then 569 // to this path until we find one that doesn't exist, then
@@ -553,36 +573,41 @@ icon_changes_listen_recursive(Eina_Inarray *stack, const char *path, Eina_Bool b
553 // monitoring the next specific child dir down until we are 573 // monitoring the next specific child dir down until we are
554 // monitoring the original path again. 574 // monitoring the original path again.
555 } 575 }
556 if (S_ISDIR(st.st_mode)) 576 if (S_ISDIR(st->st_mode))
557 { 577 {
558 unsigned int i; 578 unsigned int i;
559 const Subdir_Cache_Dir *cd = subdir_cache_get(&st, path); 579 const Subdir_Cache_Dir *cd = subdir_cache_get(st, path);
560 icon_changes_monitor_add(&st, path); 580 icon_changes_monitor_add(st, path);
561 if (cd) 581 if (cd)
562 { 582 {
583 Eina_Strbuf *buf = eina_strbuf_new();
584 if (!buf) return;
563 for (i = 0; i < cd->dirs_count; i++) 585 for (i = 0; i < cd->dirs_count; i++)
564 { 586 {
565 char buf[PATH_MAX];
566 587
567 snprintf(buf, sizeof(buf), "%s/%s", path, cd->dirs[i]); 588 eina_strbuf_append_printf(buf, "%s/%s", path, cd->dirs[i]);
568 icon_changes_listen_recursive(stack, buf, EINA_FALSE); 589 icon_changes_listen_recursive(stack, eina_strbuf_string_get(buf), EINA_FALSE);
590 eina_strbuf_reset(buf);
569 } 591 }
592 eina_strbuf_free(buf);
570 } 593 }
571 } 594 }
572 eina_inarray_pop(stack); 595 eina_inarray_pop(stack);
596 eina_mempool_free(efreetd_mp_stat, st);
573} 597}
574 598
575static void 599static void
576desktop_changes_listen_recursive(Eina_Inarray *stack, const char *path, Eina_Bool base) 600desktop_changes_listen_recursive(Eina_Inarray *stack, const char *path, Eina_Bool base)
577{ 601{
578 struct stat st; 602 struct stat *st = eina_mempool_malloc(efreetd_mp_stat, sizeof(struct stat));
603 if (!st) return;
579 604
580 if (stat(path, &st) == -1) return; 605 if (stat(path, st) == -1) return;
581 if (eina_inarray_search(stack, &st, stat_cmp) >= 0) return; 606 if (eina_inarray_search(stack, st, stat_cmp) >= 0) return;
582 if (!_check_recurse_monitor_sanity(stack, path, 10)) return; 607 if (!_check_recurse_monitor_sanity(stack, path, 10)) return;
583 eina_inarray_push(stack, &st); 608 eina_inarray_push(stack, st);
584 609
585 if ((!S_ISDIR(st.st_mode)) && (base)) 610 if ((!S_ISDIR(st->st_mode)) && (base))
586 { 611 {
587 // XXX: if it doesn't exist... walk the parent dirs back down 612 // XXX: if it doesn't exist... walk the parent dirs back down
588 // to this path until we find one that doesn't exist, then 613 // to this path until we find one that doesn't exist, then
@@ -592,23 +617,26 @@ desktop_changes_listen_recursive(Eina_Inarray *stack, const char *path, Eina_Boo
592 // monitoring the next specific child dir down until we are 617 // monitoring the next specific child dir down until we are
593 // monitoring the original path again. 618 // monitoring the original path again.
594 } 619 }
595 if (S_ISDIR(st.st_mode)) 620 if (S_ISDIR(st->st_mode))
596 { 621 {
597 unsigned int i; 622 unsigned int i;
598 const Subdir_Cache_Dir *cd = subdir_cache_get(&st, path); 623 const Subdir_Cache_Dir *cd = subdir_cache_get(st, path);
599 desktop_changes_monitor_add(&st, path); 624 desktop_changes_monitor_add(st, path);
600 if (cd) 625 if (cd)
601 { 626 {
627 Eina_Strbuf *buf = eina_strbuf_new();
628 if (!buf) return;
602 for (i = 0; i < cd->dirs_count; i++) 629 for (i = 0; i < cd->dirs_count; i++)
603 { 630 {
604 char buf[PATH_MAX]; 631 eina_strbuf_append_printf(buf, "%s/%s", path, cd->dirs[i]);
605 632 desktop_changes_listen_recursive(stack, eina_strbuf_string_get(buf), EINA_FALSE);
606 snprintf(buf, sizeof(buf), "%s/%s", path, cd->dirs[i]); 633 eina_strbuf_reset(buf);
607 desktop_changes_listen_recursive(stack, buf, EINA_FALSE);
608 } 634 }
635 eina_strbuf_free(buf);
609 } 636 }
610 } 637 }
611 eina_inarray_pop(stack); 638 eina_inarray_pop(stack);
639 eina_mempool_free(efreetd_mp_stat, st);
612} 640}
613 641
614static void 642static void
@@ -616,9 +644,10 @@ icon_changes_listen(void)
616{ 644{
617 Eina_List *l; 645 Eina_List *l;
618 Eina_List *xdg_dirs; 646 Eina_List *xdg_dirs;
619 char buf[PATH_MAX];
620 const char *dir; 647 const char *dir;
621 Eina_Inarray *stack; 648 Eina_Inarray *stack;
649 Eina_Strbuf *buf = eina_strbuf_new();
650 if (!buf) return;
622 651
623 stack = eina_inarray_new(sizeof(struct stat), 16); 652 stack = eina_inarray_new(sizeof(struct stat), 16);
624 if (!stack) return; 653 if (!stack) return;
@@ -635,22 +664,25 @@ icon_changes_listen(void)
635 xdg_dirs = efreet_data_dirs_get(); 664 xdg_dirs = efreet_data_dirs_get();
636 EINA_LIST_FOREACH(xdg_dirs, l, dir) 665 EINA_LIST_FOREACH(xdg_dirs, l, dir)
637 { 666 {
638 snprintf(buf, sizeof(buf), "%s/icons", dir); 667 eina_strbuf_append_printf(buf, "%s/icons", dir);
639 eina_inarray_flush(stack); 668 eina_inarray_flush(stack);
640 icon_changes_listen_recursive(stack, buf, EINA_TRUE); 669 icon_changes_listen_recursive(stack, eina_strbuf_string_get(buf), EINA_TRUE);
670 eina_strbuf_reset(buf);
641 } 671 }
642 672
643#ifndef STRICT_SPEC 673#ifndef STRICT_SPEC
644 EINA_LIST_FOREACH(xdg_dirs, l, dir) 674 EINA_LIST_FOREACH(xdg_dirs, l, dir)
645 { 675 {
646 snprintf(buf, sizeof(buf), "%s/pixmaps", dir); 676 eina_strbuf_append_printf(buf, "%s/pixmaps", dir);
647 eina_inarray_flush(stack); 677 eina_inarray_flush(stack);
648 icon_changes_listen_recursive(stack, buf, EINA_TRUE); 678 icon_changes_listen_recursive(stack, eina_strbuf_string_get(buf), EINA_TRUE);
679 eina_strbuf_reset(buf);
649 } 680 }
650#endif 681#endif
651 eina_inarray_flush(stack); 682 eina_inarray_flush(stack);
652 icon_changes_listen_recursive(stack, "/usr/share/pixmaps", EINA_TRUE); 683 icon_changes_listen_recursive(stack, "/usr/share/pixmaps", EINA_TRUE);
653 eina_inarray_free(stack); 684 eina_inarray_free(stack);
685 eina_strbuf_free(buf);
654} 686}
655 687
656static void 688static void
@@ -681,10 +713,11 @@ fill_list(const char *file, Eina_List **l)
681 Eina_File *f = NULL; 713 Eina_File *f = NULL;
682 Eina_Iterator *it = NULL; 714 Eina_Iterator *it = NULL;
683 Eina_File_Line *line = NULL; 715 Eina_File_Line *line = NULL;
684 char buf[PATH_MAX]; 716 Eina_Strbuf *buf = eina_strbuf_new();
685 717 if (!buf) return;
686 snprintf(buf, sizeof(buf), "%s/efreet/%s", efreet_cache_home_get(), file); 718
687 f = eina_file_open(buf, EINA_FALSE); 719 eina_strbuf_append_printf(buf, "%s/efreet/%s", efreet_cache_home_get(), file);
720 f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
688 if (!f) return; 721 if (!f) return;
689 it = eina_file_map_lines(f); 722 it = eina_file_map_lines(f);
690 if (!it) goto error; 723 if (!it) goto error;
@@ -698,6 +731,7 @@ fill_list(const char *file, Eina_List **l)
698 } 731 }
699 eina_iterator_free(it); 732 eina_iterator_free(it);
700error: 733error:
734 eina_strbuf_free(buf);
701 eina_file_close(f); 735 eina_file_close(f);
702} 736}
703 737
@@ -715,16 +749,18 @@ static void
715save_list(const char *file, Eina_List *l) 749save_list(const char *file, Eina_List *l)
716{ 750{
717 FILE *f; 751 FILE *f;
718 char buf[PATH_MAX];
719 Eina_List *ll; 752 Eina_List *ll;
720 const char *path; 753 const char *path;
754 Eina_Strbuf *buf = eina_strbuf_new();
755 if (!buf) return;
721 756
722 snprintf(buf, sizeof(buf), "%s/efreet/%s", efreet_cache_home_get(), file); 757 eina_strbuf_append_printf(buf, "%s/efreet/%s", efreet_cache_home_get(), file);
723 f = fopen(buf, "wb"); 758 f = fopen(eina_strbuf_string_get(buf), "wb");
724 if (!f) return; 759 if (!f) return;
725 EINA_LIST_FOREACH(l, ll, path) 760 EINA_LIST_FOREACH(l, ll, path)
726 fprintf(f, "%s\n", path); 761 fprintf(f, "%s\n", path);
727 fclose(f); 762 fclose(f);
763 eina_strbuf_free(buf);
728} 764}
729 765
730static int 766static int
@@ -849,15 +885,17 @@ cache_desktop_exists(void)
849static void 885static void
850mime_update_launch(void) 886mime_update_launch(void)
851{ 887{
852 char file[PATH_MAX]; 888 Eina_Strbuf *file = eina_strbuf_new();
889 if (!file) return;
853 890
854 snprintf(file, sizeof(file), 891 eina_strbuf_append_printf(file,
855 "%s/efreet/" MODULE_ARCH "/efreet_mime_cache_create", 892 "%s/efreet/" MODULE_ARCH "/efreet_mime_cache_create",
856 eina_prefix_lib_get(pfx)); 893 eina_prefix_lib_get(pfx));
857 mime_cache_exe = ecore_exe_pipe_run(file, 894 mime_cache_exe = ecore_exe_pipe_run(eina_strbuf_string_get(file),
858 ECORE_EXE_PIPE_READ | 895 ECORE_EXE_PIPE_READ |
859 ECORE_EXE_PIPE_READ_LINE_BUFFERED, 896 ECORE_EXE_PIPE_READ_LINE_BUFFERED,
860 NULL); 897 NULL);
898 eina_strbuf_free(file);
861} 899}
862 900
863static Eina_Bool 901static Eina_Bool
@@ -879,7 +917,8 @@ mime_cache_init(void)
879 Eio_Monitor *mon; 917 Eio_Monitor *mon;
880 Eina_List *datadirs, *l; 918 Eina_List *datadirs, *l;
881 const char *s; 919 const char *s;
882 char buf[PATH_MAX]; 920 Eina_Strbuf *buf = eina_strbuf_new();
921 if (!buf) return;
883 922
884 mime_monitors = eina_hash_string_superfast_new 923 mime_monitors = eina_hash_string_superfast_new
885 (EINA_FREE_CB(eio_monitor_del)); 924 (EINA_FREE_CB(eio_monitor_del));
@@ -907,20 +946,21 @@ mime_cache_init(void)
907 datadirs = efreet_data_dirs_get(); 946 datadirs = efreet_data_dirs_get();
908 EINA_LIST_FOREACH(datadirs, l, s) 947 EINA_LIST_FOREACH(datadirs, l, s)
909 { 948 {
910 snprintf(buf, sizeof(buf), "%s/mime", s); // specifically lok at XXX/mime/globs 949 eina_strbuf_append_printf(buf, "%s/mime", s); // specifically lok at XXX/mime/globs
911 if (ecore_file_is_dir(buf)) 950 if (ecore_file_is_dir(eina_strbuf_string_get(buf)))
912 { 951 {
913 if (!eina_hash_find(mime_monitors, buf)) 952 if (!eina_hash_find(mime_monitors, eina_strbuf_string_get(buf)))
914 { 953 {
915 mon = eio_monitor_add(buf); 954 mon = eio_monitor_add(eina_strbuf_string_get(buf));
916 if (mon) 955 if (mon)
917 { 956 {
918 eina_hash_add(mime_monitors, buf, mon); 957 eina_hash_add(mime_monitors, eina_strbuf_string_get(buf), mon);
919 eina_hash_add(mime_monitors_mon, &mon, mon); 958 eina_hash_add(mime_monitors_mon, &mon, mon);
920 } 959 }
921 } 960 }
922 } 961 }
923 } 962 }
963 eina_strbuf_free(buf);
924} 964}
925 965
926static void 966static void