summaryrefslogtreecommitdiff
path: root/src/bin/efreet/efreet_icon_cache_create.c
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2015-10-01 08:45:51 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-10-12 17:21:59 -0700
commit2c9848aa7e1a841dc10dff35c43b26423c67a7de (patch)
tree59d9e3adda8fbbcf28f7782cc48df40d6818a8fb /src/bin/efreet/efreet_icon_cache_create.c
parentb72be67388a4b1be53542407b63e6b649a9f6b7a (diff)
efreet: use ecore_file function instead of stat() in the icon cache code
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to '')
-rw-r--r--src/bin/efreet/efreet_icon_cache_create.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/bin/efreet/efreet_icon_cache_create.c b/src/bin/efreet/efreet_icon_cache_create.c
index 93e6566adc..8ed0fe60ee 100644
--- a/src/bin/efreet/efreet_icon_cache_create.c
+++ b/src/bin/efreet/efreet_icon_cache_create.c
@@ -2,7 +2,6 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include <sys/stat.h>
6#include <fcntl.h> 5#include <fcntl.h>
7#include <unistd.h> 6#include <unistd.h>
8#include <errno.h> 7#include <errno.h>
@@ -32,22 +31,24 @@ static Eina_Bool
32cache_directory_modified(Eina_Hash *dirs, const char *dir) 31cache_directory_modified(Eina_Hash *dirs, const char *dir)
33{ 32{
34 Efreet_Cache_Directory *dcache; 33 Efreet_Cache_Directory *dcache;
35 struct stat st; 34 long long time;
36 35
37 if (!dirs) return EINA_TRUE; 36 if (!dirs) return EINA_TRUE;
38 37
39 if (stat(dir, &st) < 0) return EINA_FALSE; 38 time = ecore_file_mod_time(dir);
39 if (!time)
40 return EINA_FALSE;
40 dcache = eina_hash_find(dirs, dir); 41 dcache = eina_hash_find(dirs, dir);
41 if (!dcache) 42 if (!dcache)
42 { 43 {
43 dcache = malloc(sizeof (Efreet_Cache_Directory)); 44 dcache = malloc(sizeof (Efreet_Cache_Directory));
44 if (!dcache) return EINA_TRUE; 45 if (!dcache) return EINA_TRUE;
45 46
46 dcache->modified_time = (long long) st.st_mtime; 47 dcache->modified_time = time;
47 eina_hash_add(dirs, dir, dcache); 48 eina_hash_add(dirs, dir, dcache);
48 } 49 }
49 else if (dcache->modified_time == (long long) st.st_mtime) return EINA_FALSE; 50 else if (dcache->modified_time == time) return EINA_FALSE;
50 dcache->modified_time = st.st_mtime; 51 dcache->modified_time = time;
51 52
52 return EINA_TRUE; 53 return EINA_TRUE;
53} 54}
@@ -478,12 +479,13 @@ icon_theme_index_read(Efreet_Cache_Icon_Theme *theme, const char *path)
478 Efreet_Ini *ini; 479 Efreet_Ini *ini;
479 Efreet_Icon_Theme_Directory *dir; 480 Efreet_Icon_Theme_Directory *dir;
480 const char *tmp; 481 const char *tmp;
481 struct stat st; 482 long long time;
482 483
483 if (!theme || !path) return EINA_FALSE; 484 if (!theme || !path) return EINA_FALSE;
484 485
485 if (stat(path, &st) < 0) return EINA_FALSE; 486 time = ecore_file_mod_time(path);
486 if (theme->path && !strcmp(theme->path, path) && theme->last_cache_check >= (long long) st.st_mtime) 487 if (!time) return EINA_FALSE;
488 if (theme->path && !strcmp(theme->path, path) && theme->last_cache_check >= time)
487 { 489 {
488 /* no change */ 490 /* no change */
489 theme->valid = 1; 491 theme->valid = 1;
@@ -494,8 +496,8 @@ icon_theme_index_read(Efreet_Cache_Icon_Theme *theme, const char *path)
494 theme->path = eina_stringshare_add(path); 496 theme->path = eina_stringshare_add(path);
495 eina_array_push(strs, theme->path); 497 eina_array_push(strs, theme->path);
496 } 498 }
497 if ((long long) st.st_mtime > theme->last_cache_check) 499 if (time > theme->last_cache_check)
498 theme->last_cache_check = (long long) st.st_mtime; 500 theme->last_cache_check = time;
499 theme->changed = 1; 501 theme->changed = 1;
500 502
501 ini = efreet_ini_new(path); 503 ini = efreet_ini_new(path);
@@ -606,13 +608,14 @@ cache_theme_scan(const char *dir)
606 608
607 EINA_ITERATOR_FOREACH(it, entry) 609 EINA_ITERATOR_FOREACH(it, entry)
608 { 610 {
611 char buf[PATH_MAX];
609 Efreet_Cache_Icon_Theme *theme; 612 Efreet_Cache_Icon_Theme *theme;
610 const char *name; 613 const char *name;
611 const char *path; 614 const char *path;
612 char buf[PATH_MAX]; 615 long long time;
613 struct stat st;
614 616
615 if (stat(entry->path, &st) < 0) continue; 617 time = ecore_file_mod_time(entry->path);
618 if (!time) continue;
616 619
617 if ((entry->type != EINA_FILE_DIR) && 620 if ((entry->type != EINA_FILE_DIR) &&
618 (entry->type != EINA_FILE_LNK)) 621 (entry->type != EINA_FILE_LNK))
@@ -634,9 +637,9 @@ cache_theme_scan(const char *dir)
634 (void *)theme->theme.name.internal, theme); 637 (void *)theme->theme.name.internal, theme);
635 theme->changed = 1; 638 theme->changed = 1;
636 } 639 }
637 if ((long long) st.st_mtime > theme->last_cache_check) 640 if (time > theme->last_cache_check)
638 { 641 {
639 theme->last_cache_check = (long long) st.st_mtime; 642 theme->last_cache_check = time;
640 theme->changed = 1; 643 theme->changed = 1;
641 } 644 }
642 645