efl/ecore_file: refactor to be more like eio in providing backends.
instead of the previous mess, just define the functions with common names and call the backend that was compiled in, similar to what eio does. also do not be silent on errors, use eina_safety_checks to issue warnings. SVN revision: 80360
This commit is contained in:
parent
6a5eaacc6a
commit
62bb4646c9
23
configure.ac
23
configure.ac
|
@ -478,6 +478,13 @@ unistd.h \
|
|||
have_inotify="${ac_cv_header_sys_inotify_h}"
|
||||
AM_CONDITIONAL([HAVE_INOTIFY], [test "x${have_inotify}" = "xyes"])
|
||||
|
||||
have_notify_win32="${have_win32}"
|
||||
AC_DEFINE_IF([HAVE_NOTIFY_WIN32],
|
||||
[test "x${have_notify_win32}" = "xyes"],
|
||||
[File monitoring with Windows notification])
|
||||
AM_CONDITIONAL([HAVE_NOTIFY_WIN32], [test "x${have_notify_win32}" = "xyes"])
|
||||
|
||||
|
||||
EFL_CHECK_PATH_MAX
|
||||
|
||||
|
||||
|
@ -2392,17 +2399,6 @@ if test "x${want_poll}" = "xyes" ; then
|
|||
have_poll="yes"
|
||||
fi
|
||||
|
||||
have_notify_win32="no"
|
||||
|
||||
case "$host_os" in
|
||||
mingw32ce*)
|
||||
;;
|
||||
mingw32*)
|
||||
have_notify_win32="yes"
|
||||
AC_DEFINE([HAVE_NOTIFY_WIN32], [1], [File monitoring with Windows notification])
|
||||
;;
|
||||
esac
|
||||
|
||||
if ! test "x${have_atfile_source}" = "xno" ; then
|
||||
AC_CHECK_FUNCS([mkdirat],
|
||||
[
|
||||
|
@ -3933,11 +3929,6 @@ setxattr("/", "user.ethumb.md5", NULL, 0, 0);
|
|||
|
||||
AC_MSG_RESULT([${have_xattr}])
|
||||
|
||||
# Check for inotify specificity
|
||||
have_notify_win32="no"
|
||||
EIO_CHECK_NOTIFY_WIN32([have_notify_win32="yes"], [have_notify_win32="no"])
|
||||
AM_CONDITIONAL([EIO_HAVE_WINCHANGE], [test "x${have_notify_win32}" = "xyes"])
|
||||
|
||||
#### End of Eio
|
||||
|
||||
|
||||
|
|
|
@ -11,12 +11,22 @@ lib_ecore_file_libecore_file_la_SOURCES = \
|
|||
lib/ecore_file/ecore_file.c \
|
||||
lib/ecore_file/ecore_file_download.c \
|
||||
lib/ecore_file/ecore_file_monitor.c \
|
||||
lib/ecore_file/ecore_file_monitor_inotify.c \
|
||||
lib/ecore_file/ecore_file_monitor_poll.c \
|
||||
lib/ecore_file/ecore_file_monitor_win32.c \
|
||||
lib/ecore_file/ecore_file_path.c \
|
||||
lib/ecore_file/ecore_file_private.h
|
||||
|
||||
if HAVE_INOTIFY
|
||||
lib_ecore_file_libecore_file_la_SOURCES += \
|
||||
lib/ecore_file/ecore_file_monitor_inotify.c
|
||||
else
|
||||
if HAVE_NOTIFY_WIN32
|
||||
lib_ecore_file_libecore_file_la_SOURCES += \
|
||||
lib/ecore_file/ecore_file_monitor_win32.c
|
||||
else
|
||||
lib_ecore_file_libecore_file_la_SOURCES += \
|
||||
lib/ecore_file/ecore_file_monitor_poll.c
|
||||
endif
|
||||
endif
|
||||
|
||||
lib_ecore_file_libecore_file_la_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src/lib/eina \
|
||||
-I$(top_srcdir)/src/lib/eo \
|
||||
|
|
|
@ -21,7 +21,7 @@ lib/eio/eio_private.h
|
|||
if HAVE_INOTIFY
|
||||
lib_eio_libeio_la_SOURCES += lib/eio/eio_monitor_inotify.c
|
||||
else
|
||||
if EIO_HAVE_WINCHANGE
|
||||
if HAVE_NOTIFY_WIN32
|
||||
lib_eio_libeio_la_SOURCES += lib/eio/eio_monitor_win32.c
|
||||
endif
|
||||
endif
|
||||
|
|
|
@ -4,66 +4,18 @@
|
|||
|
||||
#include "ecore_file_private.h"
|
||||
|
||||
typedef enum {
|
||||
ECORE_FILE_MONITOR_TYPE_NONE,
|
||||
#ifdef HAVE_SYS_INOTIFY_H
|
||||
ECORE_FILE_MONITOR_TYPE_INOTIFY,
|
||||
#endif
|
||||
#ifdef HAVE_NOTIFY_WIN32
|
||||
ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32,
|
||||
#endif
|
||||
#ifdef HAVE_POLL
|
||||
ECORE_FILE_MONITOR_TYPE_POLL
|
||||
#endif
|
||||
} Ecore_File_Monitor_Type;
|
||||
|
||||
static Ecore_File_Monitor_Type monitor_type = ECORE_FILE_MONITOR_TYPE_NONE;
|
||||
|
||||
int
|
||||
ecore_file_monitor_init(void)
|
||||
{
|
||||
#ifdef HAVE_SYS_INOTIFY_H
|
||||
monitor_type = ECORE_FILE_MONITOR_TYPE_INOTIFY;
|
||||
if (ecore_file_monitor_inotify_init())
|
||||
if (ecore_file_monitor_backend_init())
|
||||
return 1;
|
||||
#endif
|
||||
#ifdef HAVE_NOTIFY_WIN32
|
||||
monitor_type = ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32;
|
||||
if (ecore_file_monitor_win32_init())
|
||||
return 1;
|
||||
#endif
|
||||
#ifdef HAVE_POLL
|
||||
monitor_type = ECORE_FILE_MONITOR_TYPE_POLL;
|
||||
if (ecore_file_monitor_poll_init())
|
||||
return 1;
|
||||
#endif
|
||||
monitor_type = ECORE_FILE_MONITOR_TYPE_NONE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ecore_file_monitor_shutdown(void)
|
||||
{
|
||||
switch (monitor_type)
|
||||
{
|
||||
case ECORE_FILE_MONITOR_TYPE_NONE:
|
||||
break;
|
||||
#ifdef HAVE_SYS_INOTIFY_H
|
||||
case ECORE_FILE_MONITOR_TYPE_INOTIFY:
|
||||
ecore_file_monitor_inotify_shutdown();
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_NOTIFY_WIN32
|
||||
case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
|
||||
ecore_file_monitor_win32_shutdown();
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_POLL
|
||||
case ECORE_FILE_MONITOR_TYPE_POLL:
|
||||
ecore_file_monitor_poll_shutdown();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
ecore_file_monitor_backend_shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,27 +46,11 @@ ecore_file_monitor_add(const char *path,
|
|||
Ecore_File_Monitor_Cb func,
|
||||
void *data)
|
||||
{
|
||||
if (!path || !*path)
|
||||
return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(path[0] == '\0', NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
|
||||
|
||||
switch (monitor_type)
|
||||
{
|
||||
case ECORE_FILE_MONITOR_TYPE_NONE:
|
||||
return NULL;
|
||||
#ifdef HAVE_SYS_INOTIFY_H
|
||||
case ECORE_FILE_MONITOR_TYPE_INOTIFY:
|
||||
return ecore_file_monitor_inotify_add(path, func, data);
|
||||
#endif
|
||||
#ifdef HAVE_NOTIFY_WIN32
|
||||
case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
|
||||
return ecore_file_monitor_win32_add(path, func, data);
|
||||
#endif
|
||||
#ifdef HAVE_POLL
|
||||
case ECORE_FILE_MONITOR_TYPE_POLL:
|
||||
return ecore_file_monitor_poll_add(path, func, data);
|
||||
#endif
|
||||
}
|
||||
return NULL;
|
||||
return ecore_file_monitor_backend_add(path, func, data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,29 +67,8 @@ ecore_file_monitor_add(const char *path,
|
|||
EAPI void
|
||||
ecore_file_monitor_del(Ecore_File_Monitor *em)
|
||||
{
|
||||
if (!em)
|
||||
return;
|
||||
|
||||
switch (monitor_type)
|
||||
{
|
||||
case ECORE_FILE_MONITOR_TYPE_NONE:
|
||||
break;
|
||||
#ifdef HAVE_SYS_INOTIFY_H
|
||||
case ECORE_FILE_MONITOR_TYPE_INOTIFY:
|
||||
ecore_file_monitor_inotify_del(em);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_NOTIFY_WIN32
|
||||
case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
|
||||
ecore_file_monitor_win32_del(em);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_POLL
|
||||
case ECORE_FILE_MONITOR_TYPE_POLL:
|
||||
ecore_file_monitor_poll_del(em);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
EINA_SAFETY_ON_NULL_RETURN(em);
|
||||
ecore_file_monitor_backend_del(em);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,8 +85,7 @@ ecore_file_monitor_del(Ecore_File_Monitor *em)
|
|||
EAPI const char *
|
||||
ecore_file_monitor_path_get(Ecore_File_Monitor *em)
|
||||
{
|
||||
if (!em)
|
||||
return NULL;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(em, NULL);
|
||||
return em->path;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
* - Listen to IN_IGNORED, emitted when the watch is removed
|
||||
*/
|
||||
|
||||
#ifdef HAVE_SYS_INOTIFY_H
|
||||
|
||||
#include <sys/inotify.h>
|
||||
|
||||
|
||||
|
@ -48,7 +46,7 @@ static void _ecore_file_monitor_inotify_print(char *file, int mas
|
|||
#endif
|
||||
|
||||
int
|
||||
ecore_file_monitor_inotify_init(void)
|
||||
ecore_file_monitor_backend_init(void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
|
@ -69,12 +67,12 @@ ecore_file_monitor_inotify_init(void)
|
|||
}
|
||||
|
||||
int
|
||||
ecore_file_monitor_inotify_shutdown(void)
|
||||
ecore_file_monitor_backend_shutdown(void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
while(_monitors)
|
||||
ecore_file_monitor_inotify_del(_monitors);
|
||||
ecore_file_monitor_backend_del(_monitors);
|
||||
|
||||
if (_fdh)
|
||||
{
|
||||
|
@ -87,7 +85,7 @@ ecore_file_monitor_inotify_shutdown(void)
|
|||
}
|
||||
|
||||
Ecore_File_Monitor *
|
||||
ecore_file_monitor_inotify_add(const char *path,
|
||||
ecore_file_monitor_backend_add(const char *path,
|
||||
void (*func) (void *data, Ecore_File_Monitor *em,
|
||||
Ecore_File_Event event,
|
||||
const char *path),
|
||||
|
@ -100,8 +98,8 @@ ecore_file_monitor_inotify_add(const char *path,
|
|||
|
||||
if (_inotify_fd_pid != getpid())
|
||||
{
|
||||
ecore_file_monitor_inotify_shutdown();
|
||||
ecore_file_monitor_inotify_init();
|
||||
ecore_file_monitor_backend_shutdown();
|
||||
ecore_file_monitor_backend_init();
|
||||
}
|
||||
|
||||
em = calloc(1, sizeof(Ecore_File_Monitor_Inotify));
|
||||
|
@ -124,7 +122,7 @@ ecore_file_monitor_inotify_add(const char *path,
|
|||
}
|
||||
|
||||
void
|
||||
ecore_file_monitor_inotify_del(Ecore_File_Monitor *em)
|
||||
ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
|
||||
{
|
||||
int fd;
|
||||
|
||||
|
@ -283,7 +281,7 @@ _ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path)
|
|||
if (ECORE_FILE_MONITOR_INOTIFY(em)->wd < 0)
|
||||
{
|
||||
INF("inotify_add_watch failed, file was deleted");
|
||||
ecore_file_monitor_inotify_del(em);
|
||||
ecore_file_monitor_backend_del(em);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
@ -328,4 +326,3 @@ _ecore_file_monitor_inotify_print(char *file, int mask)
|
|||
INF("Inotify unmount %s: %s", type, file);
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_SYS_INOTIFY_H */
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
#include "ecore_file_private.h"
|
||||
|
||||
#ifdef HAVE_POLL
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* - Implement recursive as an option!
|
||||
|
@ -43,16 +41,16 @@ static void _ecore_file_monitor_poll_check(Ecore_File_Monitor *em);
|
|||
static int _ecore_file_monitor_poll_checking(Ecore_File_Monitor *em, char *name);
|
||||
|
||||
int
|
||||
ecore_file_monitor_poll_init(void)
|
||||
ecore_file_monitor_backend_init(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
ecore_file_monitor_poll_shutdown(void)
|
||||
ecore_file_monitor_backend_shutdown(void)
|
||||
{
|
||||
while(_monitors)
|
||||
ecore_file_monitor_poll_del(_monitors);
|
||||
ecore_file_monitor_backend_del(_monitors);
|
||||
|
||||
if (_timer)
|
||||
{
|
||||
|
@ -63,7 +61,7 @@ ecore_file_monitor_poll_shutdown(void)
|
|||
}
|
||||
|
||||
Ecore_File_Monitor *
|
||||
ecore_file_monitor_poll_add(const char *path,
|
||||
ecore_file_monitor_backend_add(const char *path,
|
||||
void (*func) (void *data, Ecore_File_Monitor *em,
|
||||
Ecore_File_Event event,
|
||||
const char *path),
|
||||
|
@ -125,7 +123,7 @@ ecore_file_monitor_poll_add(const char *path,
|
|||
}
|
||||
else
|
||||
{
|
||||
ecore_file_monitor_poll_del(em);
|
||||
ecore_file_monitor_backend_del(em);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -133,7 +131,7 @@ ecore_file_monitor_poll_add(const char *path,
|
|||
}
|
||||
|
||||
void
|
||||
ecore_file_monitor_poll_del(Ecore_File_Monitor *em)
|
||||
ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
|
||||
{
|
||||
Ecore_File *l;
|
||||
|
||||
|
@ -337,4 +335,3 @@ _ecore_file_monitor_poll_checking(Ecore_File_Monitor *em, char *name)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NOTIFY_WIN32
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
|
@ -225,19 +223,19 @@ _ecore_file_monitor_win32_cb(void *data, Ecore_Win32_Handler *wh)
|
|||
}
|
||||
|
||||
int
|
||||
ecore_file_monitor_win32_init(void)
|
||||
ecore_file_monitor_backend_init(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
ecore_file_monitor_win32_shutdown(void)
|
||||
ecore_file_monitor_backend_shutdown(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Ecore_File_Monitor *
|
||||
ecore_file_monitor_win32_add(const char *path,
|
||||
ecore_file_monitor_backend_add(const char *path,
|
||||
void (*func) (void *data, Ecore_File_Monitor *em,
|
||||
Ecore_File_Event event,
|
||||
const char *path),
|
||||
|
@ -293,7 +291,7 @@ ecore_file_monitor_win32_add(const char *path,
|
|||
}
|
||||
|
||||
void
|
||||
ecore_file_monitor_win32_del(Ecore_File_Monitor *em)
|
||||
ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
|
||||
{
|
||||
Ecore_File_Monitor_Win32 *m;
|
||||
|
||||
|
@ -306,5 +304,3 @@ ecore_file_monitor_win32_del(Ecore_File_Monitor *em)
|
|||
free(em->path);
|
||||
free(em);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -81,42 +81,15 @@ struct _Ecore_File_Monitor
|
|||
Ecore_File *files;
|
||||
};
|
||||
|
||||
#ifdef HAVE_SYS_INOTIFY_H
|
||||
int ecore_file_monitor_inotify_init(void);
|
||||
int ecore_file_monitor_inotify_shutdown(void);
|
||||
Ecore_File_Monitor *ecore_file_monitor_inotify_add(const char *path,
|
||||
void (*func) (void *data,
|
||||
Ecore_File_Monitor *ecore_file_monitor,
|
||||
Ecore_File_Event event,
|
||||
const char *path),
|
||||
void *data);
|
||||
void ecore_file_monitor_inotify_del(Ecore_File_Monitor *ecore_file_monitor);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NOTIFY_WIN32
|
||||
int ecore_file_monitor_win32_init(void);
|
||||
int ecore_file_monitor_win32_shutdown(void);
|
||||
Ecore_File_Monitor *ecore_file_monitor_win32_add(const char *path,
|
||||
void (*func) (void *data,
|
||||
Ecore_File_Monitor *ecore_file_monitor,
|
||||
Ecore_File_Event event,
|
||||
const char *path),
|
||||
void *data);
|
||||
void ecore_file_monitor_win32_del(Ecore_File_Monitor *ecore_file_monitor);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POLL
|
||||
int ecore_file_monitor_poll_init(void);
|
||||
int ecore_file_monitor_poll_shutdown(void);
|
||||
Ecore_File_Monitor *ecore_file_monitor_poll_add(const char *path,
|
||||
void (*func) (void *data,
|
||||
Ecore_File_Monitor *ecore_file_monitor,
|
||||
Ecore_File_Event event,
|
||||
const char *path),
|
||||
void *data);
|
||||
void ecore_file_monitor_poll_del(Ecore_File_Monitor *ecore_file_monitor);
|
||||
|
||||
#endif
|
||||
int ecore_file_monitor_backend_init(void);
|
||||
int ecore_file_monitor_backend_shutdown(void);
|
||||
Ecore_File_Monitor *ecore_file_monitor_backend_add(const char *path,
|
||||
void (*func) (void *data,
|
||||
Ecore_File_Monitor *ecore_file_monitor,
|
||||
Ecore_File_Event event,
|
||||
const char *path),
|
||||
void *data);
|
||||
void ecore_file_monitor_backend_del(Ecore_File_Monitor *ecore_file_monitor);
|
||||
|
||||
/* ecore_file_path */
|
||||
void ecore_file_path_init(void);
|
||||
|
|
Loading…
Reference in New Issue