#endif
static Edje_File *
-_edje_file_open(Eina_File *f, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret, time_t mtime)
+_edje_file_open(const char *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret, time_t mtime)
{
Edje_Color_Class *cc;
Edje_File *edf;
Ecore_Event_Handler *ev;
#endif
- ef = eet_mmap(f);
+ ef = eet_open(file, EET_FILE_MODE_READ);
if (!ef)
{
*error_ret = EDJE_LOAD_ERROR_UNKNOWN_FORMAT;
return NULL;
}
- edf->f = f;
edf->ef = ef;
edf->mtime = mtime;
#ifdef HAVE_EIO
- edf->monitor = eio_monitor_add(eina_file_filename_get(f));
+ edf->monitor = eio_monitor_add(file);
ev = ecore_event_handler_add(EIO_MONITOR_FILE_DELETED, _edje_file_change, edf);
edf->handlers = eina_list_append(edf->handlers, ev);
ev = ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED, _edje_file_change, edf);
if (edf->minor > EDJE_FILE_MINOR)
{
- WRN("`%s` may use feature from a newer edje and could not show up as expected.",
- eina_file_filename_get(f));
+ WRN("`%s` may use feature from a newer edje and could not show up as expected.", file);
}
- edf->path = eina_stringshare_add(eina_file_filename_get(f));
+ edf->path = eina_stringshare_add(file);
edf->references = 1;
/* This should be done at edje generation time */
return edf;
}
-#if 0
-// FIXME: find a way to remove dangling file earlier
static void
_edje_file_dangling(Edje_File *edf)
{
if (edf->dangling) return;
edf->dangling = EINA_TRUE;
- eina_hash_del(_edje_file_hash, edf->f, edf);
+ eina_hash_del(_edje_file_hash, edf->path, edf);
if (!eina_hash_population(_edje_file_hash))
{
eina_hash_free(_edje_file_hash);
_edje_file_hash = NULL;
}
}
-#endif
Edje_File *
_edje_cache_file_coll_open(const char *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret, Edje *ed)
{
- Eina_File *f;
Edje_File *edf;
Eina_List *l, *hist;
Edje_Part_Collection *edc;
Edje_Part *ep;
+ struct stat st;
- f = eina_file_open(file, EINA_FALSE);
- if (!f)
+ if (stat(file, &st) != 0)
{
*error_ret = EDJE_LOAD_ERROR_DOES_NOT_EXIST;
return NULL;
if (!_edje_file_hash)
{
- _edje_file_hash = eina_hash_pointer_new(NULL);
+ _edje_file_hash = eina_hash_string_small_new(NULL);
goto find_list;
}
- edf = eina_hash_find(_edje_file_hash, f);
+ edf = eina_hash_find(_edje_file_hash, file);
if (edf)
{
- eina_file_close(f);
+ if (edf->mtime != st.st_mtime)
+ {
+ _edje_file_dangling(edf);
+ goto open_new;
+ }
edf->references++;
goto open;
find_list:
EINA_LIST_FOREACH(_edje_file_cache, l, edf)
{
- if (edf->f == f)
+ if (!strcmp(edf->path, file))
{
- eina_file_close(f);
+ if (edf->mtime != st.st_mtime)
+ {
+ _edje_file_cache = eina_list_remove_list(_edje_file_cache, l);
+ _edje_file_free(edf);
+ goto open_new;
+ }
edf->references = 1;
_edje_file_cache = eina_list_remove_list(_edje_file_cache, l);
- eina_hash_direct_add(_edje_file_hash, f, edf);
+ eina_hash_add(_edje_file_hash, file, edf);
goto open;
}
}
- edf = _edje_file_open(f, coll, error_ret, edc_ret, eina_file_mtime_get(f));
+open_new:
+ if (!_edje_file_hash)
+ _edje_file_hash = eina_hash_string_small_new(NULL);
+
+ edf = _edje_file_open(file, coll, error_ret, edc_ret, st.st_mtime);
if (!edf)
- {
- eina_file_close(f);
- return NULL;
- }
+ return NULL;
#ifdef HAVE_EIO
if (ed) edf->edjes = eina_list_append(edf->edjes, ed);
(void) ed;
#endif
- eina_hash_direct_add(_edje_file_hash, f, edf);
- /* return edf; */
+ eina_hash_add(_edje_file_hash, file, edf);
+ return edf;
open:
if (!coll)
return;
}
- eina_hash_del(_edje_file_hash, edf->f, edf);
+ eina_hash_del(_edje_file_hash, edf->path, edf);
if (!eina_hash_population(_edje_file_hash))
{
eina_hash_free(_edje_file_hash);