aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_file
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/lib/ecore_file')
-rw-r--r--libraries/ecore/src/lib/ecore_file/Ecore_File.h190
-rw-r--r--libraries/ecore/src/lib/ecore_file/Makefile.am41
-rw-r--r--libraries/ecore/src/lib/ecore_file/Makefile.in851
-rw-r--r--libraries/ecore/src/lib/ecore_file/ecore_file.c1109
-rw-r--r--libraries/ecore/src/lib/ecore_file/ecore_file_download.c449
-rw-r--r--libraries/ecore/src/lib/ecore_file/ecore_file_monitor.c180
-rw-r--r--libraries/ecore/src/lib/ecore_file/ecore_file_monitor_inotify.c370
-rw-r--r--libraries/ecore/src/lib/ecore_file/ecore_file_monitor_poll.c340
-rw-r--r--libraries/ecore/src/lib/ecore_file/ecore_file_monitor_win32.c310
-rw-r--r--libraries/ecore/src/lib/ecore_file/ecore_file_path.c185
-rw-r--r--libraries/ecore/src/lib/ecore_file/ecore_file_private.h129
11 files changed, 0 insertions, 4154 deletions
diff --git a/libraries/ecore/src/lib/ecore_file/Ecore_File.h b/libraries/ecore/src/lib/ecore_file/Ecore_File.h
deleted file mode 100644
index e4b8851..0000000
--- a/libraries/ecore/src/lib/ecore_file/Ecore_File.h
+++ /dev/null
@@ -1,190 +0,0 @@
1#ifndef ECORE_FILE_H
2#define ECORE_FILE_H
3
4/*
5 * TODO:
6 * - More events, move/rename of directory file
7 */
8
9#include <Eina.h>
10
11#ifdef EAPI
12# undef EAPI
13#endif
14
15#ifdef _WIN32
16# ifdef EFL_ECORE_FILE_BUILD
17# ifdef DLL_EXPORT
18# define EAPI __declspec(dllexport)
19# else
20# define EAPI
21# endif /* ! DLL_EXPORT */
22# else
23# define EAPI __declspec(dllimport)
24# endif /* ! EFL_ECORE_FILE_BUILD */
25#else
26# ifdef __GNUC__
27# if __GNUC__ >= 4
28# define EAPI __attribute__ ((visibility("default")))
29# else
30# define EAPI
31# endif
32# else
33# define EAPI
34# endif
35#endif /* ! _WIN32 */
36
37/**
38 * @file Ecore_File.h
39 * @brief Files utility functions
40 */
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46/**
47 * @defgroup Ecore_File_Group Ecore_File - Files and directories convenience functions
48 *
49 * @{
50 */
51
52/**
53 * @typedef Ecore_File_Monitor
54 * Abstract type used when monitoring a directory.
55 */
56typedef struct _Ecore_File_Monitor Ecore_File_Monitor;
57
58/**
59 * @typedef Ecore_File_Download_Job
60 * Abstract type used when aborting a download.
61 */
62typedef struct _Ecore_File_Download_Job Ecore_File_Download_Job;
63
64/**
65 * @typedef Ecore_File_Event
66 * The event type returned when a file or directory is monitored.
67 */
68typedef enum _Ecore_File_Event
69{
70 ECORE_FILE_EVENT_NONE, /**< No event. */
71 ECORE_FILE_EVENT_CREATED_FILE, /**< Created file event. */
72 ECORE_FILE_EVENT_CREATED_DIRECTORY, /**< Created directory event. */
73 ECORE_FILE_EVENT_DELETED_FILE, /**< Deleted file event. */
74 ECORE_FILE_EVENT_DELETED_DIRECTORY, /**< Deleted directory event. */
75 ECORE_FILE_EVENT_DELETED_SELF, /**< Deleted monitored directory event. */
76 ECORE_FILE_EVENT_MODIFIED, /**< Modified file or directory event. */
77 ECORE_FILE_EVENT_CLOSED /**< Closed file event */
78} Ecore_File_Event;
79
80/**
81 * @typedef Ecore_File_Monitor_Cb
82 * Callback type used when a monitored directory has changes.
83 */
84typedef void (*Ecore_File_Monitor_Cb)(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path);
85
86/**
87 * @typedef Ecore_File_Download_Completion_Cb
88 * Callback type used when a download is finished.
89 */
90typedef void (*Ecore_File_Download_Completion_Cb)(void *data, const char *file, int status);
91
92/**
93 * @typedef Ecore_File_Progress_Return
94 * What to do with the download as a return from the
95 * Ecore_File_Download_Progress_Cb function, if provided.
96 */
97typedef enum _Ecore_File_Progress_Return
98{
99 ECORE_FILE_PROGRESS_CONTINUE = 0, /**< Continue the download. */
100 ECORE_FILE_PROGRESS_ABORT = 1 /**< Abort the download. */
101} Ecore_File_Progress_Return;
102
103/**
104 * @typedef Ecore_File_Download_Progress_Cb
105 * Callback type used while a download is in progress.
106 */
107typedef int (*Ecore_File_Download_Progress_Cb)(void *data,
108 const char *file,
109 long int dltotal,
110 long int dlnow,
111 long int ultotal,
112 long int ulnow);
113
114/* File operations */
115
116EAPI int ecore_file_init (void);
117EAPI int ecore_file_shutdown (void);
118EAPI long long ecore_file_mod_time (const char *file);
119EAPI long long ecore_file_size (const char *file);
120EAPI Eina_Bool ecore_file_exists (const char *file);
121EAPI Eina_Bool ecore_file_is_dir (const char *file);
122EAPI Eina_Bool ecore_file_mkdir (const char *dir);
123EAPI int ecore_file_mkdirs (const char **dirs);
124EAPI int ecore_file_mksubdirs (const char *base, const char **subdirs);
125EAPI Eina_Bool ecore_file_rmdir (const char *dir);
126EAPI Eina_Bool ecore_file_recursive_rm (const char *dir);
127EAPI Eina_Bool ecore_file_mkpath (const char *path);
128EAPI int ecore_file_mkpaths (const char **paths);
129EAPI Eina_Bool ecore_file_cp (const char *src, const char *dst);
130EAPI Eina_Bool ecore_file_mv (const char *src, const char *dst);
131EAPI Eina_Bool ecore_file_symlink (const char *src, const char *dest);
132EAPI char *ecore_file_realpath (const char *file);
133EAPI Eina_Bool ecore_file_unlink (const char *file);
134EAPI Eina_Bool ecore_file_remove (const char *file);
135EAPI const char *ecore_file_file_get (const char *path);
136EAPI char *ecore_file_dir_get (const char *path);
137EAPI Eina_Bool ecore_file_can_read (const char *file);
138EAPI Eina_Bool ecore_file_can_write (const char *file);
139EAPI Eina_Bool ecore_file_can_exec (const char *file);
140EAPI char *ecore_file_readlink (const char *link);
141EAPI Eina_List *ecore_file_ls (const char *dir);
142EAPI Eina_Iterator *ecore_file_ls_iterator (const char *dir);
143EAPI char *ecore_file_app_exe_get (const char *app);
144EAPI char *ecore_file_escape_name (const char *filename);
145EAPI char *ecore_file_strip_ext (const char *file);
146EAPI int ecore_file_dir_is_empty (const char *dir);
147
148/* Monitoring */
149
150EAPI Ecore_File_Monitor *ecore_file_monitor_add(const char *path,
151 Ecore_File_Monitor_Cb func,
152 void *data);
153EAPI void ecore_file_monitor_del(Ecore_File_Monitor *ecore_file_monitor);
154EAPI const char *ecore_file_monitor_path_get(Ecore_File_Monitor *ecore_file_monitor);
155
156/* Path */
157
158EAPI Eina_Bool ecore_file_path_dir_exists(const char *in_dir);
159EAPI Eina_Bool ecore_file_app_installed(const char *exe);
160EAPI Eina_List *ecore_file_app_list(void);
161
162/* Download */
163
164EAPI Eina_Bool ecore_file_download(const char *url,
165 const char *dst,
166 Ecore_File_Download_Completion_Cb completion_cb,
167 Ecore_File_Download_Progress_Cb progress_cb,
168 void *data,
169 Ecore_File_Download_Job **job_ret);
170EAPI Eina_Bool ecore_file_download_full(const char *url,
171 const char *dst,
172 Ecore_File_Download_Completion_Cb completion_cb,
173 Ecore_File_Download_Progress_Cb progress_cb,
174 void *data,
175 Ecore_File_Download_Job **job_ret,
176 Eina_Hash *headers);
177
178EAPI void ecore_file_download_abort_all(void);
179EAPI void ecore_file_download_abort(Ecore_File_Download_Job *job);
180EAPI Eina_Bool ecore_file_download_protocol_available(const char *protocol);
181
182/**
183 * @}
184 */
185
186#ifdef __cplusplus
187}
188#endif
189
190#endif
diff --git a/libraries/ecore/src/lib/ecore_file/Makefile.am b/libraries/ecore/src/lib/ecore_file/Makefile.am
deleted file mode 100644
index ab23ace..0000000
--- a/libraries/ecore/src/lib/ecore_file/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir)/src/lib/ecore \
5-I$(top_srcdir)/src/lib/ecore_con \
6-I$(top_builddir)/src/lib/ecore \
7@EFL_ECORE_FILE_BUILD@ \
8@CURL_CFLAGS@ \
9@EVIL_CFLAGS@ \
10@EINA_CFLAGS@ \
11@WIN32_CPPFLAGS@
12
13AM_CFLAGS = @WIN32_CFLAGS@
14
15if BUILD_ECORE_CON
16lib_ecore_con_la = $(top_builddir)/src/lib/ecore_con/libecore_con.la
17endif
18
19lib_LTLIBRARIES = libecore_file.la
20includes_HEADERS = Ecore_File.h
21includesdir = $(includedir)/ecore-@VMAJ@
22
23libecore_file_la_SOURCES = \
24ecore_file.c \
25ecore_file_monitor.c \
26ecore_file_monitor_inotify.c \
27ecore_file_monitor_win32.c \
28ecore_file_monitor_poll.c \
29ecore_file_path.c \
30ecore_file_download.c
31
32libecore_file_la_LIBADD = \
33$(top_builddir)/src/lib/ecore/libecore.la \
34$(lib_ecore_con_la) \
35@EVIL_LIBS@ \
36@EINA_LIBS@
37
38libecore_file_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
39
40EXTRA_DIST = ecore_file_private.h
41
diff --git a/libraries/ecore/src/lib/ecore_file/Makefile.in b/libraries/ecore/src/lib/ecore_file/Makefile.in
deleted file mode 100644
index a80ece3..0000000
--- a/libraries/ecore/src/lib/ecore_file/Makefile.in
+++ /dev/null
@@ -1,851 +0,0 @@
1# Makefile.in generated by automake 1.11.1 from Makefile.am.
2# @configure_input@
3
4# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
6# Inc.
7# This Makefile.in is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14# PARTICULAR PURPOSE.
15
16@SET_MAKE@
17
18
19VPATH = @srcdir@
20pkgdatadir = $(datadir)/@PACKAGE@
21pkgincludedir = $(includedir)/@PACKAGE@
22pkglibdir = $(libdir)/@PACKAGE@
23pkglibexecdir = $(libexecdir)/@PACKAGE@
24am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
25install_sh_DATA = $(install_sh) -c -m 644
26install_sh_PROGRAM = $(install_sh) -c
27install_sh_SCRIPT = $(install_sh) -c
28INSTALL_HEADER = $(INSTALL_DATA)
29transform = $(program_transform_name)
30NORMAL_INSTALL = :
31PRE_INSTALL = :
32POST_INSTALL = :
33NORMAL_UNINSTALL = :
34PRE_UNINSTALL = :
35POST_UNINSTALL = :
36build_triplet = @build@
37host_triplet = @host@
38subdir = src/lib/ecore_file
39DIST_COMMON = $(includes_HEADERS) $(srcdir)/Makefile.am \
40 $(srcdir)/Makefile.in
41ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
42am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \
43 $(top_srcdir)/m4/ac_path_generic.m4 \
44 $(top_srcdir)/m4/check_x_extension.m4 \
45 $(top_srcdir)/m4/ecore_check_module.m4 \
46 $(top_srcdir)/m4/ecore_check_options.m4 \
47 $(top_srcdir)/m4/efl_compiler_flag.m4 \
48 $(top_srcdir)/m4/efl_doxygen.m4 \
49 $(top_srcdir)/m4/efl_examples.m4 \
50 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
51 $(top_srcdir)/m4/efl_threads.m4 $(top_srcdir)/m4/gettext.m4 \
52 $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
53 $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
54 $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \
55 $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
56 $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
57 $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
58 $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/configure.ac
59am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
60 $(ACLOCAL_M4)
61mkinstalldirs = $(install_sh) -d
62CONFIG_HEADER = $(top_builddir)/config.h
63CONFIG_CLEAN_FILES =
64CONFIG_CLEAN_VPATH_FILES =
65am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
66am__vpath_adj = case $$p in \
67 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
68 *) f=$$p;; \
69 esac;
70am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
71am__install_max = 40
72am__nobase_strip_setup = \
73 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
74am__nobase_strip = \
75 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
76am__nobase_list = $(am__nobase_strip_setup); \
77 for p in $$list; do echo "$$p $$p"; done | \
78 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
79 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
80 if (++n[$$2] == $(am__install_max)) \
81 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
82 END { for (dir in files) print dir, files[dir] }'
83am__base_list = \
84 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
85 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
86am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)"
87LTLIBRARIES = $(lib_LTLIBRARIES)
88libecore_file_la_DEPENDENCIES = \
89 $(top_builddir)/src/lib/ecore/libecore.la $(lib_ecore_con_la)
90am_libecore_file_la_OBJECTS = ecore_file.lo ecore_file_monitor.lo \
91 ecore_file_monitor_inotify.lo ecore_file_monitor_win32.lo \
92 ecore_file_monitor_poll.lo ecore_file_path.lo \
93 ecore_file_download.lo
94libecore_file_la_OBJECTS = $(am_libecore_file_la_OBJECTS)
95AM_V_lt = $(am__v_lt_$(V))
96am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
97am__v_lt_0 = --silent
98libecore_file_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
99 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
100 $(AM_CFLAGS) $(CFLAGS) $(libecore_file_la_LDFLAGS) $(LDFLAGS) \
101 -o $@
102DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
103depcomp = $(SHELL) $(top_srcdir)/depcomp
104am__depfiles_maybe = depfiles
105am__mv = mv -f
106COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
107 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
108LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
109 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
110 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
111 $(AM_CFLAGS) $(CFLAGS)
112AM_V_CC = $(am__v_CC_$(V))
113am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
114am__v_CC_0 = @echo " CC " $@;
115AM_V_at = $(am__v_at_$(V))
116am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
117am__v_at_0 = @
118CCLD = $(CC)
119LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
120 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
121 $(AM_LDFLAGS) $(LDFLAGS) -o $@
122AM_V_CCLD = $(am__v_CCLD_$(V))
123am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
124am__v_CCLD_0 = @echo " CCLD " $@;
125AM_V_GEN = $(am__v_GEN_$(V))
126am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
127am__v_GEN_0 = @echo " GEN " $@;
128SOURCES = $(libecore_file_la_SOURCES)
129DIST_SOURCES = $(libecore_file_la_SOURCES)
130HEADERS = $(includes_HEADERS)
131ETAGS = etags
132CTAGS = ctags
133DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
134ACLOCAL = @ACLOCAL@
135ALLOCA = @ALLOCA@
136AMTAR = @AMTAR@
137AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
138AR = @AR@
139AS = @AS@
140AUTOCONF = @AUTOCONF@
141AUTOHEADER = @AUTOHEADER@
142AUTOMAKE = @AUTOMAKE@
143AWK = @AWK@
144CARES_CFLAGS = @CARES_CFLAGS@
145CARES_LIBS = @CARES_LIBS@
146CC = @CC@
147CCDEPMODE = @CCDEPMODE@
148CFLAGS = @CFLAGS@
149CHECK_CFLAGS = @CHECK_CFLAGS@
150CHECK_LIBS = @CHECK_LIBS@
151CPP = @CPP@
152CPPFLAGS = @CPPFLAGS@
153CURL_CFLAGS = @CURL_CFLAGS@
154CURL_LIBS = @CURL_LIBS@
155CXX = @CXX@
156CXXCPP = @CXXCPP@
157CXXDEPMODE = @CXXDEPMODE@
158CXXFLAGS = @CXXFLAGS@
159CYGPATH_W = @CYGPATH_W@
160DEFS = @DEFS@
161DEPDIR = @DEPDIR@
162DIRECTFB_CFLAGS = @DIRECTFB_CFLAGS@
163DIRECTFB_LIBS = @DIRECTFB_LIBS@
164DLLTOOL = @DLLTOOL@
165DSYMUTIL = @DSYMUTIL@
166DUMPBIN = @DUMPBIN@
167ECHO_C = @ECHO_C@
168ECHO_N = @ECHO_N@
169ECHO_T = @ECHO_T@
170ECORE_XCB_CFLAGS = @ECORE_XCB_CFLAGS@
171ECORE_XCB_LIBS = @ECORE_XCB_LIBS@
172EFL_ECORE_BUILD = @EFL_ECORE_BUILD@
173EFL_ECORE_CON_BUILD = @EFL_ECORE_CON_BUILD@
174EFL_ECORE_EVAS_BUILD = @EFL_ECORE_EVAS_BUILD@
175EFL_ECORE_FILE_BUILD = @EFL_ECORE_FILE_BUILD@
176EFL_ECORE_IMF_BUILD = @EFL_ECORE_IMF_BUILD@
177EFL_ECORE_IMF_EVAS_BUILD = @EFL_ECORE_IMF_EVAS_BUILD@
178EFL_ECORE_INPUT_BUILD = @EFL_ECORE_INPUT_BUILD@
179EFL_ECORE_INPUT_EVAS_BUILD = @EFL_ECORE_INPUT_EVAS_BUILD@
180EFL_ECORE_IPC_BUILD = @EFL_ECORE_IPC_BUILD@
181EFL_ECORE_PSL1GHT_BUILD = @EFL_ECORE_PSL1GHT_BUILD@
182EFL_ECORE_SDL_BUILD = @EFL_ECORE_SDL_BUILD@
183EFL_ECORE_WIN32_BUILD = @EFL_ECORE_WIN32_BUILD@
184EFL_ECORE_WINCE_BUILD = @EFL_ECORE_WINCE_BUILD@
185EFL_PTHREAD_CFLAGS = @EFL_PTHREAD_CFLAGS@
186EFL_PTHREAD_LIBS = @EFL_PTHREAD_LIBS@
187EGREP = @EGREP@
188EINA_CFLAGS = @EINA_CFLAGS@
189EINA_LIBS = @EINA_LIBS@
190ESCAPE_CFLAGS = @ESCAPE_CFLAGS@
191ESCAPE_LIBS = @ESCAPE_LIBS@
192EVAS_CFLAGS = @EVAS_CFLAGS@
193EVAS_LIBS = @EVAS_LIBS@
194EVIL_CFLAGS = @EVIL_CFLAGS@
195EVIL_LIBS = @EVIL_LIBS@
196EXEEXT = @EXEEXT@
197EXOTIC_CFLAGS = @EXOTIC_CFLAGS@
198EXOTIC_LIBS = @EXOTIC_LIBS@
199FGREP = @FGREP@
200GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
201GLIB_CFLAGS = @GLIB_CFLAGS@
202GLIB_LIBS = @GLIB_LIBS@
203GMSGFMT = @GMSGFMT@
204GMSGFMT_015 = @GMSGFMT_015@
205GREP = @GREP@
206INSTALL = @INSTALL@
207INSTALL_DATA = @INSTALL_DATA@
208INSTALL_PROGRAM = @INSTALL_PROGRAM@
209INSTALL_SCRIPT = @INSTALL_SCRIPT@
210INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
211INTLLIBS = @INTLLIBS@
212INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
213KEYSYMDEFS = @KEYSYMDEFS@
214LD = @LD@
215LDFLAGS = @LDFLAGS@
216LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
217LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
218LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
219LIBICONV = @LIBICONV@
220LIBINTL = @LIBINTL@
221LIBOBJS = @LIBOBJS@
222LIBS = @LIBS@
223LIBTOOL = @LIBTOOL@
224LIPO = @LIPO@
225LN_S = @LN_S@
226LTLIBICONV = @LTLIBICONV@
227LTLIBINTL = @LTLIBINTL@
228LTLIBOBJS = @LTLIBOBJS@
229MAKEINFO = @MAKEINFO@
230MKDIR_P = @MKDIR_P@
231MSGFMT = @MSGFMT@
232MSGFMT_015 = @MSGFMT_015@
233MSGMERGE = @MSGMERGE@
234NM = @NM@
235NMEDIT = @NMEDIT@
236OBJC = @OBJC@
237OBJCDEPMODE = @OBJCDEPMODE@
238OBJCFLAGS = @OBJCFLAGS@
239OBJDUMP = @OBJDUMP@
240OBJEXT = @OBJEXT@
241OTOOL = @OTOOL@
242OTOOL64 = @OTOOL64@
243PACKAGE = @PACKAGE@
244PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
245PACKAGE_NAME = @PACKAGE_NAME@
246PACKAGE_STRING = @PACKAGE_STRING@
247PACKAGE_TARNAME = @PACKAGE_TARNAME@
248PACKAGE_URL = @PACKAGE_URL@
249PACKAGE_VERSION = @PACKAGE_VERSION@
250PATH_SEPARATOR = @PATH_SEPARATOR@
251PIXMAN_CFLAGS = @PIXMAN_CFLAGS@
252PIXMAN_LIBS = @PIXMAN_LIBS@
253PKG_CONFIG = @PKG_CONFIG@
254PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
255PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
256POSUB = @POSUB@
257RANLIB = @RANLIB@
258SCIM_CFLAGS = @SCIM_CFLAGS@
259SCIM_LIBS = @SCIM_LIBS@
260SDL_CFLAGS = @SDL_CFLAGS@
261SDL_CONFIG = @SDL_CONFIG@
262SDL_LIBS = @SDL_LIBS@
263SED = @SED@
264SET_MAKE = @SET_MAKE@
265SHELL = @SHELL@
266SHM_OPEN_LIBS = @SHM_OPEN_LIBS@
267SSL_CFLAGS = @SSL_CFLAGS@
268SSL_LIBS = @SSL_LIBS@
269STRIP = @STRIP@
270TLS2_CFLAGS = @TLS2_CFLAGS@
271TLS2_LIBS = @TLS2_LIBS@
272TLS_CFLAGS = @TLS_CFLAGS@
273TLS_LIBS = @TLS_LIBS@
274TSLIB_CFLAGS = @TSLIB_CFLAGS@
275TSLIB_LIBS = @TSLIB_LIBS@
276USE_NLS = @USE_NLS@
277VERSION = @VERSION@
278VMAJ = @VMAJ@
279WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
280WAYLAND_EGL_CFLAGS = @WAYLAND_EGL_CFLAGS@
281WAYLAND_EGL_LIBS = @WAYLAND_EGL_LIBS@
282WAYLAND_LIBS = @WAYLAND_LIBS@
283WIN32_CFLAGS = @WIN32_CFLAGS@
284WIN32_CPPFLAGS = @WIN32_CPPFLAGS@
285WIN32_LIBS = @WIN32_LIBS@
286XCB_COMPOSITE_CFLAGS = @XCB_COMPOSITE_CFLAGS@
287XCB_COMPOSITE_LIBS = @XCB_COMPOSITE_LIBS@
288XCB_CURSOR_CFLAGS = @XCB_CURSOR_CFLAGS@
289XCB_CURSOR_LIBS = @XCB_CURSOR_LIBS@
290XCB_DAMAGE_CFLAGS = @XCB_DAMAGE_CFLAGS@
291XCB_DAMAGE_LIBS = @XCB_DAMAGE_LIBS@
292XCB_DPMS_CFLAGS = @XCB_DPMS_CFLAGS@
293XCB_DPMS_LIBS = @XCB_DPMS_LIBS@
294XCB_RANDR_CFLAGS = @XCB_RANDR_CFLAGS@
295XCB_RANDR_LIBS = @XCB_RANDR_LIBS@
296XCB_RENDER_CFLAGS = @XCB_RENDER_CFLAGS@
297XCB_RENDER_LIBS = @XCB_RENDER_LIBS@
298XCB_SCREENSAVER_CFLAGS = @XCB_SCREENSAVER_CFLAGS@
299XCB_SCREENSAVER_LIBS = @XCB_SCREENSAVER_LIBS@
300XCB_SHAPE_CFLAGS = @XCB_SHAPE_CFLAGS@
301XCB_SHAPE_LIBS = @XCB_SHAPE_LIBS@
302XCB_SYNC_CFLAGS = @XCB_SYNC_CFLAGS@
303XCB_SYNC_LIBS = @XCB_SYNC_LIBS@
304XCB_X11_CFLAGS = @XCB_X11_CFLAGS@
305XCB_X11_LIBS = @XCB_X11_LIBS@
306XCB_XFIXES_CFLAGS = @XCB_XFIXES_CFLAGS@
307XCB_XFIXES_LIBS = @XCB_XFIXES_LIBS@
308XCB_XGESTURE_CFLAGS = @XCB_XGESTURE_CFLAGS@
309XCB_XGESTURE_LIBS = @XCB_XGESTURE_LIBS@
310XCB_XINERAMA_CFLAGS = @XCB_XINERAMA_CFLAGS@
311XCB_XINERAMA_LIBS = @XCB_XINERAMA_LIBS@
312XCB_XINPUT_CFLAGS = @XCB_XINPUT_CFLAGS@
313XCB_XINPUT_LIBS = @XCB_XINPUT_LIBS@
314XCB_XPRINT_CFLAGS = @XCB_XPRINT_CFLAGS@
315XCB_XPRINT_LIBS = @XCB_XPRINT_LIBS@
316XCB_XTEST_CFLAGS = @XCB_XTEST_CFLAGS@
317XCB_XTEST_LIBS = @XCB_XTEST_LIBS@
318XCOMPOSITE_CFLAGS = @XCOMPOSITE_CFLAGS@
319XCOMPOSITE_LIBS = @XCOMPOSITE_LIBS@
320XDAMAGE_CFLAGS = @XDAMAGE_CFLAGS@
321XDAMAGE_LIBS = @XDAMAGE_LIBS@
322XDPMS_CFLAGS = @XDPMS_CFLAGS@
323XDPMS_LIBS = @XDPMS_LIBS@
324XFIXES_CFLAGS = @XFIXES_CFLAGS@
325XFIXES_LIBS = @XFIXES_LIBS@
326XGESTURE_CFLAGS = @XGESTURE_CFLAGS@
327XGESTURE_LIBS = @XGESTURE_LIBS@
328XGETTEXT = @XGETTEXT@
329XGETTEXT_015 = @XGETTEXT_015@
330XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
331XI2_CFLAGS = @XI2_CFLAGS@
332XI2_LIBS = @XI2_LIBS@
333XINERAMA_CFLAGS = @XINERAMA_CFLAGS@
334XINERAMA_LIBS = @XINERAMA_LIBS@
335XKB_CFLAGS = @XKB_CFLAGS@
336XKB_LIBS = @XKB_LIBS@
337XMKMF = @XMKMF@
338XPRINT_CFLAGS = @XPRINT_CFLAGS@
339XPRINT_LIBS = @XPRINT_LIBS@
340XRANDR_CFLAGS = @XRANDR_CFLAGS@
341XRANDR_LIBS = @XRANDR_LIBS@
342XRENDER_CFLAGS = @XRENDER_CFLAGS@
343XRENDER_LIBS = @XRENDER_LIBS@
344XSS_CFLAGS = @XSS_CFLAGS@
345XSS_LIBS = @XSS_LIBS@
346XTEST_CFLAGS = @XTEST_CFLAGS@
347XTEST_LIBS = @XTEST_LIBS@
348X_CFLAGS = @X_CFLAGS@
349X_EXTRA_LIBS = @X_EXTRA_LIBS@
350X_LIBS = @X_LIBS@
351X_PRE_LIBS = @X_PRE_LIBS@
352Xcursor_cflags = @Xcursor_cflags@
353Xcursor_libs = @Xcursor_libs@
354abs_builddir = @abs_builddir@
355abs_srcdir = @abs_srcdir@
356abs_top_builddir = @abs_top_builddir@
357abs_top_srcdir = @abs_top_srcdir@
358ac_ct_CC = @ac_ct_CC@
359ac_ct_CXX = @ac_ct_CXX@
360ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
361ac_ct_OBJC = @ac_ct_OBJC@
362am__include = @am__include@
363am__leading_dot = @am__leading_dot@
364am__quote = @am__quote@
365am__tar = @am__tar@
366am__untar = @am__untar@
367bindir = @bindir@
368build = @build@
369build_alias = @build_alias@
370build_cpu = @build_cpu@
371build_os = @build_os@
372build_vendor = @build_vendor@
373builddir = @builddir@
374cocoa_ldflags = @cocoa_ldflags@
375datadir = @datadir@
376datarootdir = @datarootdir@
377dlopen_libs = @dlopen_libs@
378docdir = @docdir@
379dvidir = @dvidir@
380ecore_cocoa_cflags = @ecore_cocoa_cflags@
381ecore_cocoa_libs = @ecore_cocoa_libs@
382ecore_con_cflags = @ecore_con_cflags@
383ecore_con_libs = @ecore_con_libs@
384ecore_directfb_cflags = @ecore_directfb_cflags@
385ecore_directfb_libs = @ecore_directfb_libs@
386ecore_evas_cflags = @ecore_evas_cflags@
387ecore_evas_libs = @ecore_evas_libs@
388ecore_fb_cflags = @ecore_fb_cflags@
389ecore_fb_libs = @ecore_fb_libs@
390ecore_file_cflags = @ecore_file_cflags@
391ecore_file_libs = @ecore_file_libs@
392ecore_imf_cflags = @ecore_imf_cflags@
393ecore_imf_evas_cflags = @ecore_imf_evas_cflags@
394ecore_imf_evas_libs = @ecore_imf_evas_libs@
395ecore_imf_libs = @ecore_imf_libs@
396ecore_imf_scim_cflags = @ecore_imf_scim_cflags@
397ecore_imf_scim_libs = @ecore_imf_scim_libs@
398ecore_imf_xim_cflags = @ecore_imf_xim_cflags@
399ecore_imf_xim_libs = @ecore_imf_xim_libs@
400ecore_input_cflags = @ecore_input_cflags@
401ecore_input_evas_cflags = @ecore_input_evas_cflags@
402ecore_input_evas_libs = @ecore_input_evas_libs@
403ecore_input_libs = @ecore_input_libs@
404ecore_ipc_cflags = @ecore_ipc_cflags@
405ecore_ipc_libs = @ecore_ipc_libs@
406ecore_psl1ght_cflags = @ecore_psl1ght_cflags@
407ecore_psl1ght_libs = @ecore_psl1ght_libs@
408ecore_sdl_cflags = @ecore_sdl_cflags@
409ecore_sdl_libs = @ecore_sdl_libs@
410ecore_wayland_cflags = @ecore_wayland_cflags@
411ecore_wayland_libs = @ecore_wayland_libs@
412ecore_win32_cflags = @ecore_win32_cflags@
413ecore_win32_libs = @ecore_win32_libs@
414ecore_wince_cflags = @ecore_wince_cflags@
415ecore_wince_libs = @ecore_wince_libs@
416ecore_x_cflags = @ecore_x_cflags@
417ecore_x_libs = @ecore_x_libs@
418ecore_x_libs_private = @ecore_x_libs_private@
419efl_doxygen = @efl_doxygen@
420efl_have_doxygen = @efl_have_doxygen@
421exec_prefix = @exec_prefix@
422have_ecore_x_xcb_define = @have_ecore_x_xcb_define@
423host = @host@
424host_alias = @host_alias@
425host_cpu = @host_cpu@
426host_os = @host_os@
427host_vendor = @host_vendor@
428htmldir = @htmldir@
429includedir = @includedir@
430infodir = @infodir@
431install_sh = @install_sh@
432libdir = @libdir@
433libexecdir = @libexecdir@
434localedir = @localedir@
435localstatedir = @localstatedir@
436lt_ECHO = @lt_ECHO@
437lt_enable_auto_import = @lt_enable_auto_import@
438mandir = @mandir@
439mkdir_p = @mkdir_p@
440oldincludedir = @oldincludedir@
441pdfdir = @pdfdir@
442pkgconfig_requires_private = @pkgconfig_requires_private@
443prefix = @prefix@
444program_transform_name = @program_transform_name@
445psdir = @psdir@
446release_info = @release_info@
447requirements_ecore = @requirements_ecore@
448requirements_ecore_cocoa = @requirements_ecore_cocoa@
449requirements_ecore_con = @requirements_ecore_con@
450requirements_ecore_directfb = @requirements_ecore_directfb@
451requirements_ecore_evas = @requirements_ecore_evas@
452requirements_ecore_fb = @requirements_ecore_fb@
453requirements_ecore_file = @requirements_ecore_file@
454requirements_ecore_imf = @requirements_ecore_imf@
455requirements_ecore_imf_evas = @requirements_ecore_imf_evas@
456requirements_ecore_imf_scim = @requirements_ecore_imf_scim@
457requirements_ecore_imf_xim = @requirements_ecore_imf_xim@
458requirements_ecore_input = @requirements_ecore_input@
459requirements_ecore_input_evas = @requirements_ecore_input_evas@
460requirements_ecore_ipc = @requirements_ecore_ipc@
461requirements_ecore_psl1ght = @requirements_ecore_psl1ght@
462requirements_ecore_sdl = @requirements_ecore_sdl@
463requirements_ecore_wayland = @requirements_ecore_wayland@
464requirements_ecore_win32 = @requirements_ecore_win32@
465requirements_ecore_wince = @requirements_ecore_wince@
466requirements_ecore_x = @requirements_ecore_x@
467rt_libs = @rt_libs@
468sbindir = @sbindir@
469sharedstatedir = @sharedstatedir@
470srcdir = @srcdir@
471sysconfdir = @sysconfdir@
472target_alias = @target_alias@
473top_build_prefix = @top_build_prefix@
474top_builddir = @top_builddir@
475top_srcdir = @top_srcdir@
476version_info = @version_info@
477x_cflags = @x_cflags@
478x_includes = @x_includes@
479x_libs = @x_libs@
480MAINTAINERCLEANFILES = Makefile.in
481AM_CPPFLAGS = \
482-I$(top_srcdir)/src/lib/ecore \
483-I$(top_srcdir)/src/lib/ecore_con \
484-I$(top_builddir)/src/lib/ecore \
485@EFL_ECORE_FILE_BUILD@ \
486@CURL_CFLAGS@ \
487@EVIL_CFLAGS@ \
488@EINA_CFLAGS@ \
489@WIN32_CPPFLAGS@
490
491AM_CFLAGS = @WIN32_CFLAGS@
492@BUILD_ECORE_CON_TRUE@lib_ecore_con_la = $(top_builddir)/src/lib/ecore_con/libecore_con.la
493lib_LTLIBRARIES = libecore_file.la
494includes_HEADERS = Ecore_File.h
495includesdir = $(includedir)/ecore-@VMAJ@
496libecore_file_la_SOURCES = \
497ecore_file.c \
498ecore_file_monitor.c \
499ecore_file_monitor_inotify.c \
500ecore_file_monitor_win32.c \
501ecore_file_monitor_poll.c \
502ecore_file_path.c \
503ecore_file_download.c
504
505libecore_file_la_LIBADD = \
506$(top_builddir)/src/lib/ecore/libecore.la \
507$(lib_ecore_con_la) \
508@EVIL_LIBS@ \
509@EINA_LIBS@
510
511libecore_file_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
512EXTRA_DIST = ecore_file_private.h
513all: all-am
514
515.SUFFIXES:
516.SUFFIXES: .c .lo .o .obj
517$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
518 @for dep in $?; do \
519 case '$(am__configure_deps)' in \
520 *$$dep*) \
521 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
522 && { if test -f $@; then exit 0; else break; fi; }; \
523 exit 1;; \
524 esac; \
525 done; \
526 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/lib/ecore_file/Makefile'; \
527 $(am__cd) $(top_srcdir) && \
528 $(AUTOMAKE) --gnu src/lib/ecore_file/Makefile
529.PRECIOUS: Makefile
530Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
531 @case '$?' in \
532 *config.status*) \
533 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
534 *) \
535 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
536 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
537 esac;
538
539$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
540 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
541
542$(top_srcdir)/configure: $(am__configure_deps)
543 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
544$(ACLOCAL_M4): $(am__aclocal_m4_deps)
545 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
546$(am__aclocal_m4_deps):
547install-libLTLIBRARIES: $(lib_LTLIBRARIES)
548 @$(NORMAL_INSTALL)
549 test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
550 @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
551 list2=; for p in $$list; do \
552 if test -f $$p; then \
553 list2="$$list2 $$p"; \
554 else :; fi; \
555 done; \
556 test -z "$$list2" || { \
557 echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
558 $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
559 }
560
561uninstall-libLTLIBRARIES:
562 @$(NORMAL_UNINSTALL)
563 @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
564 for p in $$list; do \
565 $(am__strip_dir) \
566 echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
567 $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
568 done
569
570clean-libLTLIBRARIES:
571 -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
572 @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
573 dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
574 test "$$dir" != "$$p" || dir=.; \
575 echo "rm -f \"$${dir}/so_locations\""; \
576 rm -f "$${dir}/so_locations"; \
577 done
578libecore_file.la: $(libecore_file_la_OBJECTS) $(libecore_file_la_DEPENDENCIES)
579 $(AM_V_CCLD)$(libecore_file_la_LINK) -rpath $(libdir) $(libecore_file_la_OBJECTS) $(libecore_file_la_LIBADD) $(LIBS)
580
581mostlyclean-compile:
582 -rm -f *.$(OBJEXT)
583
584distclean-compile:
585 -rm -f *.tab.c
586
587@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_file.Plo@am__quote@
588@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_file_download.Plo@am__quote@
589@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_file_monitor.Plo@am__quote@
590@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_file_monitor_inotify.Plo@am__quote@
591@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_file_monitor_poll.Plo@am__quote@
592@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_file_monitor_win32.Plo@am__quote@
593@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_file_path.Plo@am__quote@
594
595.c.o:
596@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
597@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
598@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
599@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
600@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
601@am__fastdepCC_FALSE@ $(COMPILE) -c $<
602
603.c.obj:
604@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
605@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
606@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
607@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
608@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
609@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
610
611.c.lo:
612@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
613@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
614@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
615@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
616@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
617@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
618
619mostlyclean-libtool:
620 -rm -f *.lo
621
622clean-libtool:
623 -rm -rf .libs _libs
624install-includesHEADERS: $(includes_HEADERS)
625 @$(NORMAL_INSTALL)
626 test -z "$(includesdir)" || $(MKDIR_P) "$(DESTDIR)$(includesdir)"
627 @list='$(includes_HEADERS)'; test -n "$(includesdir)" || list=; \
628 for p in $$list; do \
629 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
630 echo "$$d$$p"; \
631 done | $(am__base_list) | \
632 while read files; do \
633 echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includesdir)'"; \
634 $(INSTALL_HEADER) $$files "$(DESTDIR)$(includesdir)" || exit $$?; \
635 done
636
637uninstall-includesHEADERS:
638 @$(NORMAL_UNINSTALL)
639 @list='$(includes_HEADERS)'; test -n "$(includesdir)" || list=; \
640 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
641 test -n "$$files" || exit 0; \
642 echo " ( cd '$(DESTDIR)$(includesdir)' && rm -f" $$files ")"; \
643 cd "$(DESTDIR)$(includesdir)" && rm -f $$files
644
645ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
646 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
647 unique=`for i in $$list; do \
648 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
649 done | \
650 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
651 END { if (nonempty) { for (i in files) print i; }; }'`; \
652 mkid -fID $$unique
653tags: TAGS
654
655TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
656 $(TAGS_FILES) $(LISP)
657 set x; \
658 here=`pwd`; \
659 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
660 unique=`for i in $$list; do \
661 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
662 done | \
663 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
664 END { if (nonempty) { for (i in files) print i; }; }'`; \
665 shift; \
666 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
667 test -n "$$unique" || unique=$$empty_fix; \
668 if test $$# -gt 0; then \
669 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
670 "$$@" $$unique; \
671 else \
672 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
673 $$unique; \
674 fi; \
675 fi
676ctags: CTAGS
677CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
678 $(TAGS_FILES) $(LISP)
679 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
680 unique=`for i in $$list; do \
681 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
682 done | \
683 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
684 END { if (nonempty) { for (i in files) print i; }; }'`; \
685 test -z "$(CTAGS_ARGS)$$unique" \
686 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
687 $$unique
688
689GTAGS:
690 here=`$(am__cd) $(top_builddir) && pwd` \
691 && $(am__cd) $(top_srcdir) \
692 && gtags -i $(GTAGS_ARGS) "$$here"
693
694distclean-tags:
695 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
696
697distdir: $(DISTFILES)
698 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
699 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
700 list='$(DISTFILES)'; \
701 dist_files=`for file in $$list; do echo $$file; done | \
702 sed -e "s|^$$srcdirstrip/||;t" \
703 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
704 case $$dist_files in \
705 */*) $(MKDIR_P) `echo "$$dist_files" | \
706 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
707 sort -u` ;; \
708 esac; \
709 for file in $$dist_files; do \
710 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
711 if test -d $$d/$$file; then \
712 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
713 if test -d "$(distdir)/$$file"; then \
714 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
715 fi; \
716 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
717 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
718 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
719 fi; \
720 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
721 else \
722 test -f "$(distdir)/$$file" \
723 || cp -p $$d/$$file "$(distdir)/$$file" \
724 || exit 1; \
725 fi; \
726 done
727check-am: all-am
728check: check-am
729all-am: Makefile $(LTLIBRARIES) $(HEADERS)
730installdirs:
731 for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)"; do \
732 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
733 done
734install: install-am
735install-exec: install-exec-am
736install-data: install-data-am
737uninstall: uninstall-am
738
739install-am: all-am
740 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
741
742installcheck: installcheck-am
743install-strip:
744 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
745 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
746 `test -z '$(STRIP)' || \
747 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
748mostlyclean-generic:
749
750clean-generic:
751
752distclean-generic:
753 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
754 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
755
756maintainer-clean-generic:
757 @echo "This command is intended for maintainers to use"
758 @echo "it deletes files that may require special tools to rebuild."
759 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
760clean: clean-am
761
762clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
763 mostlyclean-am
764
765distclean: distclean-am
766 -rm -rf ./$(DEPDIR)
767 -rm -f Makefile
768distclean-am: clean-am distclean-compile distclean-generic \
769 distclean-tags
770
771dvi: dvi-am
772
773dvi-am:
774
775html: html-am
776
777html-am:
778
779info: info-am
780
781info-am:
782
783install-data-am: install-includesHEADERS
784
785install-dvi: install-dvi-am
786
787install-dvi-am:
788
789install-exec-am: install-libLTLIBRARIES
790
791install-html: install-html-am
792
793install-html-am:
794
795install-info: install-info-am
796
797install-info-am:
798
799install-man:
800
801install-pdf: install-pdf-am
802
803install-pdf-am:
804
805install-ps: install-ps-am
806
807install-ps-am:
808
809installcheck-am:
810
811maintainer-clean: maintainer-clean-am
812 -rm -rf ./$(DEPDIR)
813 -rm -f Makefile
814maintainer-clean-am: distclean-am maintainer-clean-generic
815
816mostlyclean: mostlyclean-am
817
818mostlyclean-am: mostlyclean-compile mostlyclean-generic \
819 mostlyclean-libtool
820
821pdf: pdf-am
822
823pdf-am:
824
825ps: ps-am
826
827ps-am:
828
829uninstall-am: uninstall-includesHEADERS uninstall-libLTLIBRARIES
830
831.MAKE: install-am install-strip
832
833.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
834 clean-libLTLIBRARIES clean-libtool ctags distclean \
835 distclean-compile distclean-generic distclean-libtool \
836 distclean-tags distdir dvi dvi-am html html-am info info-am \
837 install install-am install-data install-data-am install-dvi \
838 install-dvi-am install-exec install-exec-am install-html \
839 install-html-am install-includesHEADERS install-info \
840 install-info-am install-libLTLIBRARIES install-man install-pdf \
841 install-pdf-am install-ps install-ps-am install-strip \
842 installcheck installcheck-am installdirs maintainer-clean \
843 maintainer-clean-generic mostlyclean mostlyclean-compile \
844 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
845 tags uninstall uninstall-am uninstall-includesHEADERS \
846 uninstall-libLTLIBRARIES
847
848
849# Tell versions [3.59,3.63) of GNU make to not export all variables.
850# Otherwise a system limit (for SysV at least) may be exceeded.
851.NOEXPORT:
diff --git a/libraries/ecore/src/lib/ecore_file/ecore_file.c b/libraries/ecore/src/lib/ecore_file/ecore_file.c
deleted file mode 100644
index cb03717..0000000
--- a/libraries/ecore/src/lib/ecore_file/ecore_file.c
+++ /dev/null
@@ -1,1109 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7#include <string.h>
8
9#ifndef _MSC_VER
10# include <unistd.h>
11# include <libgen.h>
12#endif
13
14#ifdef _WIN32
15# include <direct.h>
16#endif
17
18#ifdef HAVE_FEATURES_H
19# include <features.h>
20#endif
21#include <ctype.h>
22#include <errno.h>
23
24#ifdef HAVE_ATFILE_SOURCE
25# include <dirent.h>
26#endif
27
28#include "ecore_file_private.h"
29
30int _ecore_file_log_dom = -1;
31static int _ecore_file_init_count = 0;
32
33/* externally accessible functions */
34
35/**
36 * @addtogroup Ecore_File_Group Ecore_File - Files and directories convenience functions
37 *
38 * @{
39 */
40
41/**
42 * @brief Initialize the Ecore_File library.
43 *
44 * @return 1 or greater on success, 0 on error.
45 *
46 * This function sets up Ecore_File and the services it will use
47 * (monitoring, downloading, PATH related feature). It returns 0 on
48 * failure, otherwise it returns the number of times it has already
49 * been called.
50 *
51 * When Ecore_File is not used anymore, call ecore_file_shutdown()
52 * to shut down the Ecore_File library.
53 */
54EAPI int
55ecore_file_init()
56{
57 if (++_ecore_file_init_count != 1)
58 return _ecore_file_init_count;
59
60 if (!ecore_init())
61 return --_ecore_file_init_count;
62
63 _ecore_file_log_dom = eina_log_domain_register
64 ("ecore_file", ECORE_FILE_DEFAULT_LOG_COLOR);
65 if(_ecore_file_log_dom < 0)
66 {
67 EINA_LOG_ERR("Impossible to create a log domain for the ecore file module.");
68 return --_ecore_file_init_count;
69 }
70 ecore_file_path_init();
71 ecore_file_monitor_init();
72 ecore_file_download_init();
73
74 /* FIXME: were the tests disabled for a good reason ? */
75
76 /*
77 if (!ecore_file_monitor_init())
78 goto shutdown_ecore_file_path;
79
80 if (!ecore_file_download_init())
81 goto shutdown_ecore_file_monitor;
82 */
83
84 return _ecore_file_init_count;
85
86 /*
87 shutdown_ecore_file_monitor:
88 ecore_file_monitor_shutdown();
89 shutdown_ecore_file_path:
90 ecore_file_path_shutdown();
91
92 return --_ecore_file_init_count;
93 */
94}
95
96/**
97 * @brief Shut down the Ecore_File library.
98 *
99 * @return 0 when the library is completely shut down, 1 or
100 * greater otherwise.
101 *
102 * This function shuts down the Ecore_File library. It returns 0 when it has
103 * been called the same number of times than ecore_file_init(). In that case
104 * it shuts down all the services it uses.
105 */
106EAPI int
107ecore_file_shutdown()
108{
109 if (--_ecore_file_init_count != 0)
110 return _ecore_file_init_count;
111
112 ecore_file_download_shutdown();
113 ecore_file_monitor_shutdown();
114 ecore_file_path_shutdown();
115
116 eina_log_domain_unregister(_ecore_file_log_dom);
117 _ecore_file_log_dom = -1;
118
119 ecore_shutdown();
120
121 return _ecore_file_init_count;
122}
123
124/**
125 * @brief Get the time of the last modification to the given file.
126 *
127 * @param file The name of the file.
128 * @return Return the time of the last data modification, or 0 on
129 * failure.
130 *
131 * This function returns the time of the last modification of
132 * @p file. On failure, it returns 0.
133 */
134EAPI long long
135ecore_file_mod_time(const char *file)
136{
137 struct stat st;
138
139 if (stat(file, &st) < 0) return 0;
140 return st.st_mtime;
141}
142
143/**
144 * @brief Get the size of the given file.
145 *
146 * @param file The name of the file.
147 * @return Return the size of the file in bytes, or 0 on failure.
148 *
149 * This function returns the size of @p file in bytes. On failure, it
150 * returns 0.
151 */
152EAPI long long
153ecore_file_size(const char *file)
154{
155 struct stat st;
156
157 if (stat(file, &st) < 0) return 0;
158 return st.st_size;
159}
160
161/**
162 * @brief Check if the given file exists.
163 *
164 * @param file The name of the file.
165 * @return Return EINA_TRUE if the file exists, EINA_FALSE otherwise.
166 *
167 * This function returns EINA_TRUE if @p file exists on local filesystem,
168 * EINA_FALSE otherwise.
169 */
170EAPI Eina_Bool
171ecore_file_exists(const char *file)
172{
173 struct stat st;
174 if (!file) return EINA_FALSE;
175
176 /*Workaround so that "/" returns a true, otherwise we can't monitor "/" in ecore_file_monitor*/
177 if (stat(file, &st) < 0 && strcmp(file, "/")) return EINA_FALSE;
178 return EINA_TRUE;
179}
180
181/**
182 * @brief Check if the given file is a directory.
183 *
184 * @param file The name of the file.
185 * @return Return EINA_TRUE if the file exists and is a directory,
186 * EINA_FALSE otherwise.
187 *
188 * This function returns EINA_TRUE if @p file exists exists and is a
189 * directory on local filesystem, EINA_FALSE otherwise.
190 */
191EAPI Eina_Bool
192ecore_file_is_dir(const char *file)
193{
194 struct stat st;
195
196 if (stat(file, &st) < 0) return EINA_FALSE;
197 if (S_ISDIR(st.st_mode)) return EINA_TRUE;
198 return EINA_FALSE;
199}
200
201static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
202
203/**
204 * @brief Create a new directory.
205 *
206 * @param dir The name of the directory to create
207 * @return EINA_TRUE on successful creation, EINA_FALSE otherwise.
208 *
209 * This function creates the directory @p dir with the mode S_IRUSR |
210 * S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH. On
211 * success, it returns EINA_TRUE, EINA_FALSE otherwise.
212 */
213EAPI Eina_Bool
214ecore_file_mkdir(const char *dir)
215{
216 if (mkdir(dir, default_mode) < 0) return EINA_FALSE;
217 return EINA_TRUE;
218}
219
220/**
221 * @brief Create complete directory in a batch.
222 *
223 * @param dirs The list of directories, null terminated.
224 * @return The number of successful directories created, -1 if dirs is
225 * @c NULL.
226 *
227 * This function creates all the directories that are in the null
228 * terminated array @p dirs. The function loops over the directories
229 * and call ecore_file_mkdir(). This function returns -1 if @p dirs is
230 * @c NULL, otherwise if returns the number of suceesfully created
231 * directories.
232 */
233EAPI int
234ecore_file_mkdirs(const char **dirs)
235{
236 int i = 0;
237
238 if (!dirs) return -1;
239
240 for (; *dirs; dirs++)
241 if (ecore_file_mkdir(*dirs))
242 i++;
243 return i;
244}
245
246/**
247 * @brief Create complete list of sub-directories in a batch (optimized).
248 *
249 * @param base The base directory to act on.
250 * @param subdirs The list of directories, null terminated.
251 * @return number of successful directories created, -1 on failure.
252 *
253 * This function creates all the directories that are in the null
254 * terminated array @p dirs in the @p base directory. If @p base does
255 * not exist, it will be created. The function loops over the directories
256 * and call ecore_file_mkdir(). The whole path of the directories must
257 * exist. So if base/a/b/c wants to be created, @p subdirs must
258 * contain "a", "a/b" and "a/b/c", in that order. This function
259 * returns -1 if @p dirs or @p base are @c NULL, or if @p base is
260 * empty ("\0"). It returns 0 is @p base is not a directory or
261 * invalid, or if it can't be created. Otherwise if returns the number
262 * of suceesfully created directories.
263 */
264EAPI int
265ecore_file_mksubdirs(const char *base, const char **subdirs)
266{
267#ifndef HAVE_ATFILE_SOURCE
268 char buf[PATH_MAX];
269 int baselen;
270#else
271 int fd;
272 DIR *dir;
273#endif
274 int i;
275
276 if (!subdirs) return -1;
277 if ((!base) || (base[0] == '\0')) return -1;
278
279 if ((!ecore_file_is_dir(base)) && (!ecore_file_mkpath(base)))
280 return 0;
281
282#ifndef HAVE_ATFILE_SOURCE
283 baselen = eina_strlcpy(buf, base, sizeof(buf));
284 if ((baselen < 1) || (baselen + 1 >= (int)sizeof(buf)))
285 return 0;
286
287 if (buf[baselen - 1] != '/')
288 {
289 buf[baselen] = '/';
290 baselen++;
291 }
292#else
293 dir = opendir(base);
294 if (!dir)
295 return 0;
296 fd = dirfd(dir);
297#endif
298
299 i = 0;
300 for (; *subdirs; subdirs++)
301 {
302 struct stat st;
303
304#ifndef HAVE_ATFILE_SOURCE
305 eina_strlcpy(buf + baselen, *subdirs, sizeof(buf) - baselen);
306 if (stat(buf, &st) == 0)
307#else
308 if (fstatat(fd, *subdirs, &st, 0) == 0)
309#endif
310 {
311 if (S_ISDIR(st.st_mode))
312 {
313 i++;
314 continue;
315 }
316 }
317 else
318 {
319 if (errno == ENOENT)
320 {
321#ifndef HAVE_ATFILE_SOURCE
322 if (mkdir(buf, default_mode) == 0)
323#else
324 if (mkdirat(fd, *subdirs, default_mode) == 0)
325#endif
326 {
327 i++;
328 continue;
329 }
330 }
331 }
332 }
333
334#ifdef HAVE_ATFILE_SOURCE
335 closedir(dir);
336#endif
337
338 return i;
339}
340
341/**
342 * @brief Delete the given directory.
343 *
344 * @param dir The name of the directory to delete.
345 * @return EINA_TRUE on success, EINA_FALSE otherwise.
346 *
347 * This function deletes @p dir. It returns EINA_TRUE on success,
348 * EINA_FALSE otherwise.
349 */
350EAPI Eina_Bool
351ecore_file_rmdir(const char *dir)
352{
353 if (rmdir(dir) < 0) return EINA_FALSE;
354 return EINA_TRUE;
355}
356
357/**
358 * @brief Delete the given file.
359 *
360 * @param file The name of the file to delete.
361 * @return EINA_TRUE on success, EINA_FALSE otherwise.
362 *
363 * This function deletes @p file. It returns EINA_TRUE on success,
364 * EINA_FALSE otherwise.
365 */
366EAPI Eina_Bool
367ecore_file_unlink(const char *file)
368{
369 if (unlink(file) < 0) return EINA_FALSE;
370 return EINA_TRUE;
371}
372
373/**
374 * @brief Remove the given file or directory.
375 *
376 * @param file The name of the file or directory to delete.
377 * @return EINA_TRUE on success, EINA_FALSE otherwise.
378 *
379 * This function removes @p file. It returns EINA_TRUE on success,
380 * EINA_FALSE otherwise.
381 */
382EAPI Eina_Bool
383ecore_file_remove(const char *file)
384{
385 if (remove(file) < 0) return EINA_FALSE;
386 return EINA_TRUE;
387}
388
389/**
390 * @brief Delete the given directory and all its contents.
391 *
392 * @param dir The name of the directory to delete.
393 * @return EINA_TRUE on success, EINA_FALSE otherwise.
394 *
395 * This function delete @p dir and all its contents. If @p dir is a
396 * link only the link is removed. It returns EINA_TRUE on success,
397 * EINA_FALSE otherwise.
398 */
399EAPI Eina_Bool
400ecore_file_recursive_rm(const char *dir)
401{
402 Eina_Iterator *it;
403 char buf[PATH_MAX];
404 struct stat st;
405 int ret;
406
407 if (readlink(dir, buf, sizeof(buf)) > 0)
408 return ecore_file_unlink(dir);
409
410 ret = stat(dir, &st);
411 if ((ret == 0) && (S_ISDIR(st.st_mode)))
412 {
413 Eina_File_Direct_Info *info;
414
415 ret = 1;
416 if (stat(dir, &st) == -1) return EINA_FALSE; /* WOOT: WHY ARE WE CALLING STAT TWO TIMES ??? */
417
418 it = eina_file_direct_ls(dir);
419 EINA_ITERATOR_FOREACH(it, info)
420 {
421 if (!ecore_file_recursive_rm(info->path))
422 ret = 0;
423 }
424 eina_iterator_free(it);
425
426 if (!ecore_file_rmdir(dir)) ret = 0;
427 if (ret)
428 return EINA_TRUE;
429 else
430 return EINA_FALSE;
431 }
432 else
433 {
434 if (ret == -1) return EINA_FALSE;
435 return ecore_file_unlink(dir);
436 }
437}
438
439static inline Eina_Bool
440_ecore_file_mkpath_if_not_exists(const char *path)
441{
442 struct stat st;
443
444 /* Windows: path like C: or D: etc are valid, but stat() returns an error */
445#ifdef _WIN32
446 if ((strlen(path) == 2) &&
447 ((path[0] >= 'a' && path[0] <= 'z') ||
448 (path[0] >= 'A' && path[0] <= 'Z')) &&
449 (path[1] == ':'))
450 return EINA_TRUE;
451#endif
452
453 if (stat(path, &st) < 0)
454 return ecore_file_mkdir(path);
455 else if (!S_ISDIR(st.st_mode))
456 return EINA_FALSE;
457 else
458 return EINA_TRUE;
459}
460
461/**
462 * @brief Create a complete path.
463 *
464 * @param path The path to create
465 * @return EINA_TRUE on success, EINA_FALSE otherwise.
466 *
467 * This function creates @p path and all the subdirectories it
468 * contains. The separator is '/' or '\'. If @p path exists, this
469 * function returns EINA_TRUE immediately. It returns EINA_TRUE on
470 * success, EINA_FALSE otherwise.
471 */
472EAPI Eina_Bool
473ecore_file_mkpath(const char *path)
474{
475 char ss[PATH_MAX];
476 unsigned int i;
477
478 if (ecore_file_is_dir(path))
479 return EINA_TRUE;
480
481 for (i = 0; path[i] != '\0'; ss[i] = path[i], i++)
482 {
483 if (i == sizeof(ss) - 1) return EINA_FALSE;
484 if (((path[i] == '/') || (path[i] == '\\')) && (i > 0))
485 {
486 ss[i] = '\0';
487 if (!_ecore_file_mkpath_if_not_exists(ss))
488 return EINA_FALSE;
489 }
490 }
491 ss[i] = '\0';
492 return _ecore_file_mkpath_if_not_exists(ss);
493}
494
495/**
496 * @brief Create complete paths in a batch.
497 *
498 * @param paths list of paths, null terminated.
499 * @return number of successful paths created, -1 if paths is NULL.
500 *
501 * This function creates all the directories that are in the null
502 * terminated array @p paths. The function loops over the directories
503 * and call ecore_file_mkpath(), hence on Windows, '\' must be
504 * replaced by '/' before calling that function. This function
505 * returns -1 if @p paths is @c NULL. Otherwise if returns the number
506 * of suceesfully created directories.
507 */
508EAPI int
509ecore_file_mkpaths(const char **paths)
510{
511 int i = 0;
512
513 if (!paths) return -1;
514
515 for (; *paths; paths++)
516 if (ecore_file_mkpath(*paths))
517 i++;
518 return i;
519}
520
521/**
522 * @brief Copy the given file to the given destination.
523 *
524 * @param src The name of the source file.
525 * @param dst The name of the destination file.
526 * @return EINA_TRUE on success, EINA_FALSE otherwise.
527 *
528 * This function copies @p src to @p dst. If the absolute path name of
529 * @p src and @p dst can not be computed, or if they are equal, or if
530 * the copy fails, the function returns EINA_FALSE, otherwise it
531 * returns EINA_TRUE.
532 */
533EAPI Eina_Bool
534ecore_file_cp(const char *src, const char *dst)
535{
536 FILE *f1, *f2;
537 char buf[16384];
538 char realpath1[PATH_MAX], realpath2[PATH_MAX];
539 size_t num;
540 Eina_Bool ret = EINA_TRUE;
541
542 if (!realpath(src, realpath1)) return EINA_FALSE;
543 if (realpath(dst, realpath2) && !strcmp(realpath1, realpath2)) return EINA_FALSE;
544
545 f1 = fopen(src, "rb");
546 if (!f1) return EINA_FALSE;
547 f2 = fopen(dst, "wb");
548 if (!f2)
549 {
550 fclose(f1);
551 return EINA_FALSE;
552 }
553 while ((num = fread(buf, 1, sizeof(buf), f1)) > 0)
554 {
555 if (fwrite(buf, 1, num, f2) != num) ret = EINA_FALSE;
556 }
557 fclose(f1);
558 fclose(f2);
559 return ret;
560}
561
562/**
563 * @brief Move the given file to the given destination.
564 *
565 * @param src The name of the source file.
566 * @param dst The name of the destination file.
567 * @return EINA_TRUE on success, EINA_FALSE otherwise.
568 *
569 * This function moves @p src to @p dst. It returns EINA_TRUE on
570 * success, EINA_FALSE otherwise.
571 */
572EAPI Eina_Bool
573ecore_file_mv(const char *src, const char *dst)
574{
575 char buf[PATH_MAX];
576 int fd;
577
578 if (rename(src, dst))
579 {
580 // File cannot be moved directly because
581 // it resides on a different mount point.
582 if (errno == EXDEV)
583 {
584 struct stat st;
585
586 // Make sure this is a regular file before
587 // we do anything fancy.
588 stat(src, &st);
589 if (S_ISREG(st.st_mode))
590 {
591 char *dir;
592
593 dir = ecore_file_dir_get(dst);
594 // Since we can't directly rename, try to
595 // copy to temp file in the dst directory
596 // and then rename.
597 snprintf(buf, sizeof(buf), "%s/.%s.tmp.XXXXXX",
598 dir, ecore_file_file_get(dst));
599 free(dir);
600 fd = mkstemp(buf);
601 if (fd < 0) goto FAIL;
602 close(fd);
603
604 // Copy to temp file
605 if (!ecore_file_cp(src, buf))
606 goto FAIL;
607
608 // Set file permissions of temp file to match src
609 chmod(buf, st.st_mode);
610
611 // Try to atomically move temp file to dst
612 if (rename(buf, dst))
613 {
614 // If we still cannot atomically move
615 // do a normal copy and hope for the best.
616 if (!ecore_file_cp(buf, dst))
617 goto FAIL;
618 }
619
620 // Delete temporary file and src
621 ecore_file_unlink(buf);
622 ecore_file_unlink(src);
623 goto PASS;
624 }
625 }
626 goto FAIL;
627 }
628
629PASS:
630 return EINA_TRUE;
631
632FAIL:
633 return EINA_FALSE;
634}
635
636/**
637 * @brief Create a symbolic link.
638 *
639 * @param src The name of the file to link.
640 * @param dest The name of link.
641 * @return EINA_TRUE on success, EINA_FALSE otherwise.
642 *
643 * This function create the symbolic link @p dest of @p src. This
644 * function does not work on Windows. It returns EINA_TRUE on success,
645 * EINA_FALSE otherwise.
646 */
647EAPI Eina_Bool
648ecore_file_symlink(const char *src, const char *dest)
649{
650 if (!symlink(src, dest)) return EINA_TRUE;
651
652 return EINA_FALSE;
653}
654
655/**
656 * @brief Get the canonicalized absolute path name.
657 *
658 * @param file The file path.
659 * @return The canonicalized absolute pathname or an empty string on
660 * failure.
661 *
662 * This function returns the absolute path name of @p file as a newly
663 * allocated string. If @p file is @c NULL, or on error, this function
664 * returns an empty string. Otherwise, it returns the absolute path
665 * name. When not needed anymore, the returned value must be freed.
666 */
667EAPI char *
668ecore_file_realpath(const char *file)
669{
670 char buf[PATH_MAX];
671
672 /*
673 * Some implementations of realpath do not conform to the SUS.
674 * And as a result we must prevent a null arg from being passed.
675 */
676 if (!file) return strdup("");
677 if (!realpath(file, buf)) return strdup("");
678
679 return strdup(buf);
680}
681
682/**
683 * Get the filename from a given path.
684 *
685 * @param path The complete path.
686 * @return The file name.
687 *
688 * This function returns the file name of @p path. If @p path is
689 * @c NULL, the functions returns @c NULL.
690 */
691EAPI const char *
692ecore_file_file_get(const char *path)
693{
694 char *result = NULL;
695
696 if (!path) return NULL;
697 if ((result = strrchr(path, '/'))) result++;
698 else result = (char *)path;
699 return result;
700}
701
702/**
703 * @brief Get the directory where the given file resides.
704 *
705 * @param file The name of the file.
706 * @return The directory name.
707 *
708 * This function returns the directory where @p file resides as anewly
709 * allocated string. If @p file is @c NULL or on error, this function
710 * returns @c NULL. When not needed anymore, the returned value must
711 * be freed.
712 */
713EAPI char *
714ecore_file_dir_get(const char *file)
715{
716 char *p;
717 char buf[PATH_MAX];
718
719 if (!file) return NULL;
720 strncpy(buf, file, PATH_MAX);
721 buf[PATH_MAX - 1] = 0;
722 p = dirname(buf);
723 return strdup(p);
724}
725
726/**
727 * @brief Check if the given file can be read.
728 *
729 * @param file The name of the file.
730 * @return EINA_TRUE if the file is readable, EINA_FALSE otherwise.
731 *
732 * This function returns EINA_TRUE if @p file can be read, EINA_FALSE
733 * otherwise.
734 */
735EAPI Eina_Bool
736ecore_file_can_read(const char *file)
737{
738 if (!file) return EINA_FALSE;
739 if (!access(file, R_OK)) return EINA_TRUE;
740 return EINA_FALSE;
741}
742
743/**
744 * @brief Check if the given file can be written.
745 *
746 * @param file The name of the file.
747 * @return EINA_TRUE if the file is writable, EINA_FALSE otherwise.
748 *
749 * This function returns EINA_TRUE if @p file can be written, EINA_FALSE
750 * otherwise.
751 */
752EAPI Eina_Bool
753ecore_file_can_write(const char *file)
754{
755 if (!file) return EINA_FALSE;
756 if (!access(file, W_OK)) return EINA_TRUE;
757 return EINA_FALSE;
758}
759
760/**
761 * @brief Check if the given file can be executed.
762 *
763 * @param file The name of the file.
764 * @return EINA_TRUE if the file can be executed, EINA_FALSE otherwise.
765 *
766 * This function returns EINA_TRUE if @p file can be executed, EINA_FALSE
767 * otherwise.
768 */
769EAPI Eina_Bool
770ecore_file_can_exec(const char *file)
771{
772 if (!file) return EINA_FALSE;
773 if (!access(file, X_OK)) return EINA_TRUE;
774 return EINA_FALSE;
775}
776
777/**
778 * @brief Get the path pointed by the given link.
779 *
780 * @param lnk The name of the link.
781 * @return The path pointed by link or NULL.
782 *
783 * This function returns the path pointed by @p link as a newly
784 * allocated string. This function does not work on Windows. On
785 * failure, the function returns @c NULL. When not needed anymore, the
786 * returned value must be freed.
787 */
788EAPI char *
789ecore_file_readlink(const char *lnk)
790{
791 char buf[PATH_MAX];
792 int count;
793
794 if ((count = readlink(lnk, buf, sizeof(buf) - 1)) < 0) return NULL;
795 buf[count] = 0;
796 return strdup(buf);
797}
798
799/**
800 * @brief Get the list of the files and directories in the given
801 * directory.
802 *
803 * @param dir The name of the directory to list
804 * @return Return an Eina_List containing all the files in the directory;
805 * on failure it returns NULL.
806 *
807 * This function returns a list of allocated strings of all the files
808 * and directories contained in @p dir. The list will be sorted with
809 * strcoll as compare function. That means that you may want to set
810 * the current locale for the category LC_COLLATE with
811 * setlocale(). For more information see the manual pages of strcoll
812 * and setlocale. The list will not contain the directory entries for
813 * '.' and '..'. On failure, @c NULL is returned. When not needed
814 * anymore, the list elements must be freed.
815 */
816EAPI Eina_List *
817ecore_file_ls(const char *dir)
818{
819 Eina_File_Direct_Info *info;
820 Eina_Iterator *ls;
821 Eina_List *list = NULL;
822
823 ls = eina_file_direct_ls(dir);
824 if (!ls) return NULL;
825
826 EINA_ITERATOR_FOREACH(ls, info)
827 {
828 char *f;
829
830 f = strdup(info->path + info->name_start);
831 list = eina_list_append(list, f);
832 }
833 eina_iterator_free(ls);
834
835 list = eina_list_sort(list, eina_list_count(list), EINA_COMPARE_CB(strcoll));
836
837 return list;
838}
839
840/**
841 * @brief Return the executable from the given command.
842 *
843 * @param app The application command, with parameters.
844 *
845 * This function returns the executable from @p app as a newly
846 * allocated string. Arguments are removed and escae characters are
847 * handled. If @p app is @c NULL, or on failure, the function returns
848 * @c NULL. When not needed anymore, the returned value must be freed.
849 */
850EAPI char *
851ecore_file_app_exe_get(const char *app)
852{
853 char *p, *pp, *exe1 = NULL, *exe2 = NULL;
854 char *exe = NULL;
855 int in_quot_dbl = 0, in_quot_sing = 0, restart = 0;
856
857 if (!app) return NULL;
858
859 p = (char *)app;
860restart:
861 while ((*p) && (isspace((unsigned char)*p))) p++;
862 exe1 = p;
863 while (*p)
864 {
865 if (in_quot_sing)
866 {
867 if (*p == '\'')
868 in_quot_sing = 0;
869 }
870 else if (in_quot_dbl)
871 {
872 if (*p == '\"')
873 in_quot_dbl = 0;
874 }
875 else
876 {
877 if (*p == '\'')
878 in_quot_sing = 1;
879 else if (*p == '\"')
880 in_quot_dbl = 1;
881 if ((isspace((unsigned char)*p)) && ((p <= app) || (p[-1] == '\\')))
882 break;
883 }
884 p++;
885 }
886 exe2 = p;
887 if (exe2 == exe1) return NULL;
888 if (*exe1 == '~')
889 {
890 char *homedir;
891 int len;
892
893 /* Skip ~ */
894 exe1++;
895
896 homedir = getenv("HOME");
897 if (!homedir) return NULL;
898 len = strlen(homedir);
899 if (exe) free(exe);
900 exe = malloc(len + exe2 - exe1 + 2);
901 if (!exe) return NULL;
902 pp = exe;
903 if (len)
904 {
905 strcpy(exe, homedir);
906 pp += len;
907 if (*(pp - 1) != '/')
908 {
909 *pp = '/';
910 pp++;
911 }
912 }
913 }
914 else
915 {
916 if (exe) free(exe);
917 exe = malloc(exe2 - exe1 + 1);
918 if (!exe) return NULL;
919 pp = exe;
920 }
921 p = exe1;
922 restart = 0;
923 in_quot_dbl = 0;
924 in_quot_sing = 0;
925 while (*p)
926 {
927 if (in_quot_sing)
928 {
929 if (*p == '\'')
930 in_quot_sing = 0;
931 else
932 {
933 *pp = *p;
934 pp++;
935 }
936 }
937 else if (in_quot_dbl)
938 {
939 if (*p == '\"')
940 in_quot_dbl = 0;
941 else
942 {
943 /* technically this is wrong. double quotes also accept
944 * special chars:
945 *
946 * $, `, \
947 */
948 *pp = *p;
949 pp++;
950 }
951 }
952 else
953 {
954 /* technically we should handle special chars:
955 *
956 * $, `, \, etc.
957 */
958 if ((p > exe1) && (p[-1] == '\\'))
959 {
960 if (*p != '\n')
961 {
962 *pp = *p;
963 pp++;
964 }
965 }
966 else if ((p > exe1) && (*p == '='))
967 {
968 restart = 1;
969 *pp = *p;
970 pp++;
971 }
972 else if (*p == '\'')
973 in_quot_sing = 1;
974 else if (*p == '\"')
975 in_quot_dbl = 1;
976 else if (isspace((unsigned char)*p))
977 {
978 if (restart)
979 goto restart;
980 else
981 break;
982 }
983 else
984 {
985 *pp = *p;
986 pp++;
987 }
988 }
989 p++;
990 }
991 *pp = 0;
992 return exe;
993}
994
995/**
996 * @brief Add the escape sequence ('\\') to the given file name.
997 *
998 * @param filename The file name.
999 * @return The file name with special characters escaped.
1000 *
1001 * This function adds the escape sequence ('\\') to the given file
1002 * name and returns the result as a newly allocated string. If the
1003 * length of the returned string is longer than PATH_MAX, or on
1004 * failure, @c NULL is returned. When not needed anymore, the returned
1005 * value must be freed.
1006 */
1007EAPI char *
1008ecore_file_escape_name(const char *filename)
1009{
1010 const char *p;
1011 char *q;
1012 char buf[PATH_MAX];
1013
1014 p = filename;
1015 q = buf;
1016 while (*p)
1017 {
1018 if ((q - buf) > (PATH_MAX - 6)) return NULL;
1019 if (
1020 (*p == ' ') || (*p == '\t') || (*p == '\n') ||
1021 (*p == '\\') || (*p == '\'') || (*p == '\"') ||
1022 (*p == ';') || (*p == '!') || (*p == '#') ||
1023 (*p == '$') || (*p == '%') || (*p == '&') ||
1024 (*p == '*') || (*p == '(') || (*p == ')') ||
1025 (*p == '[') || (*p == ']') || (*p == '{') ||
1026 (*p == '}') || (*p == '|') || (*p == '<') ||
1027 (*p == '>') || (*p == '?')
1028 )
1029 {
1030 *q = '\\';
1031 q++;
1032 }
1033 *q = *p;
1034 q++;
1035 p++;
1036 }
1037 *q = 0;
1038 return strdup(buf);
1039}
1040
1041/**
1042 * @brief Remove the extension from the given file name.
1043 *
1044 * @param path The name of the file.
1045 * @return A newly allocated string with the extension stripped out or
1046 * NULL on errors.
1047 *
1048 * This function removes the extension from @p path and returns the
1049 * result as a newly allocated string. If @p path is @c NULL, or on
1050 * failure, the function returns @c NULL. When not needed anymore, the
1051 * returned value must be freed.
1052 */
1053EAPI char *
1054ecore_file_strip_ext(const char *path)
1055{
1056 char *p, *file = NULL;
1057
1058 if (!path)
1059 return NULL;
1060
1061 p = strrchr(path, '.');
1062 if (!p)
1063 file = strdup(path);
1064 else if (p != path)
1065 {
1066 file = malloc(((p - path) + 1) * sizeof(char));
1067 if (file)
1068 {
1069 memcpy(file, path, (p - path));
1070 file[p - path] = 0;
1071 }
1072 }
1073
1074 return file;
1075}
1076
1077/**
1078 * @brief Check if the given directory is empty.
1079 *
1080 * @param dir The name of the directory to check.
1081 * @return 1 if directory is empty, 0 if it has at least one file or
1082 * -1 in case of errors.
1083 *
1084 * This functions checks if @p dir is empty. The '.' and '..' files
1085 * will be ignored. If @p dir is empty, 1 is returned, if it contains
1086 * at least 1 file, 0 is returned. On failure, -1 is returned.
1087 */
1088EAPI int
1089ecore_file_dir_is_empty(const char *dir)
1090{
1091 Eina_File_Direct_Info *info;
1092 Eina_Iterator *it;
1093
1094 it = eina_file_direct_ls(dir);
1095 if (!it) return -1;
1096
1097 EINA_ITERATOR_FOREACH(it, info)
1098 {
1099 eina_iterator_free(it);
1100 return 0;
1101 }
1102
1103 eina_iterator_free(it);
1104 return 1;
1105}
1106
1107/**
1108 * @}
1109 */
diff --git a/libraries/ecore/src/lib/ecore_file/ecore_file_download.c b/libraries/ecore/src/lib/ecore_file/ecore_file_download.c
deleted file mode 100644
index 971493e..0000000
--- a/libraries/ecore/src/lib/ecore_file/ecore_file_download.c
+++ /dev/null
@@ -1,449 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7#include <string.h>
8
9#ifdef BUILD_ECORE_CON
10# include "Ecore_Con.h"
11#endif
12
13#include "ecore_file_private.h"
14
15#ifdef BUILD_ECORE_CON
16
17#define ECORE_MAGIC_FILE_DOWNLOAD_JOB 0xf7427cb8
18#define ECORE_FILE_DOWNLOAD_TIMEOUT 30
19
20struct _Ecore_File_Download_Job
21{
22 ECORE_MAGIC;
23
24 Ecore_Con_Url *url_con;
25 FILE *file;
26
27 char *dst;
28
29 Ecore_File_Download_Completion_Cb completion_cb;
30 Ecore_File_Download_Progress_Cb progress_cb;
31};
32
33#ifdef HAVE_CURL
34Ecore_File_Download_Job *_ecore_file_download_curl(const char *url, const char *dst,
35 Ecore_File_Download_Completion_Cb completion_cb,
36 Ecore_File_Download_Progress_Cb progress_cb,
37 void *data,
38 Eina_Hash *headers);
39
40static Eina_Bool _ecore_file_download_url_complete_cb(void *data, int type, void *event);
41static Eina_Bool _ecore_file_download_url_progress_cb(void *data, int type, void *event);
42#endif
43
44static Ecore_Event_Handler *_url_complete_handler = NULL;
45static Ecore_Event_Handler *_url_progress_download = NULL;
46static Eina_List *_job_list;
47
48static int download_init = 0;
49
50#endif /* BUILD_ECORE_CON */
51
52int
53ecore_file_download_init(void)
54{
55#ifdef BUILD_ECORE_CON
56 download_init++;
57 if (download_init > 1) return 1;
58 if (!ecore_con_init()) return 0;
59 if (!ecore_con_url_init())
60 {
61 ecore_con_shutdown();
62 return 0;
63 }
64# ifdef HAVE_CURL
65 _url_complete_handler = ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _ecore_file_download_url_complete_cb, NULL);
66 _url_progress_download = ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS, _ecore_file_download_url_progress_cb, NULL);
67# endif
68#endif /* BUILD_ECORE_CON */
69 return 1;
70}
71
72void
73ecore_file_download_shutdown(void)
74{
75#ifdef BUILD_ECORE_CON
76 download_init--;
77 if (download_init > 0) return;
78 if (_url_complete_handler)
79 ecore_event_handler_del(_url_complete_handler);
80 if (_url_progress_download)
81 ecore_event_handler_del(_url_progress_download);
82 _url_complete_handler = NULL;
83 _url_progress_download = NULL;
84 ecore_file_download_abort_all();
85 ecore_con_url_shutdown();
86 ecore_con_shutdown();
87#endif /* BUILD_ECORE_CON */
88}
89
90#ifdef BUILD_ECORE_CON
91# ifdef HAVE_CURL
92static Eina_Bool
93_ecore_file_download_headers_foreach_cb(const Eina_Hash *hash __UNUSED__, const void *key, void *data, void *fdata)
94{
95 Ecore_File_Download_Job *job = fdata;
96 ecore_con_url_additional_header_add(job->url_con, key, data);
97
98 return EINA_TRUE;
99}
100# endif
101#endif
102
103static Eina_Bool
104_ecore_file_download(const char *url,
105 const char *dst,
106 Ecore_File_Download_Completion_Cb completion_cb,
107 Ecore_File_Download_Progress_Cb progress_cb,
108 void *data,
109 Ecore_File_Download_Job **job_ret,
110 Eina_Hash *headers)
111{
112#ifdef BUILD_ECORE_CON
113 char *dir = ecore_file_dir_get(dst);
114
115 if (!ecore_file_is_dir(dir))
116 {
117 ERR("%s is not a directory", dir);
118 free(dir);
119 return EINA_FALSE;
120 }
121 free(dir);
122 if (ecore_file_exists(dst))
123 {
124 WRN("%s already exists", dst);
125 return EINA_FALSE;
126 }
127
128 if (!strncmp(url, "file://", 7))
129 {
130 /* FIXME: Maybe fork? Might take a while to copy.
131 * Check filesize? */
132 /* Just copy it */
133
134 url += 7;
135 /* skip hostname */
136 url = strchr(url, '/');
137 return ecore_file_cp(url, dst);
138 }
139# ifdef HAVE_CURL
140 else if ((!strncmp(url, "http://", 7)) || (!strncmp(url, "https://", 8)) ||
141 (!strncmp(url, "ftp://", 6)))
142 {
143 /* download */
144 Ecore_File_Download_Job *job;
145
146 job = _ecore_file_download_curl(url, dst, completion_cb, progress_cb, data, headers);
147 if(job_ret) *job_ret = job;
148 if(job)
149 return EINA_TRUE;
150 else
151 {
152 ERR("no job returned\n");
153 return EINA_FALSE;
154 }
155 return job ? EINA_TRUE : EINA_FALSE;
156 }
157# else
158 else if ((!strncmp(url, "http://", 7)) || (!strncmp(url, "https://", 8)) ||
159 (!strncmp(url, "ftp://", 6)))
160 {
161 (void)completion_cb;
162 (void)progress_cb;
163 (void)data;
164 (void)job_ret;
165 (void)headers;
166 return EINA_FALSE;
167 }
168# endif
169 else
170 {
171 return EINA_FALSE;
172 }
173#else
174 (void)url;
175 (void)dst;
176 (void)completion_cb;
177 (void)progress_cb;
178 (void)data;
179 (void)job_ret;
180 (void)headers;
181 return EINA_FALSE;
182#endif /* BUILD_ECORE_CON */
183}
184
185/**
186 * @addtogroup Ecore_File_Group Ecore_File - Files and directories convenience functions
187 *
188 * @{
189 */
190
191/**
192 * @brief Download the given url to the given destination.
193 *
194 * @param url The complete url to download.
195 * @param dst The local file to save the downloaded to.
196 * @param completion_cb A callback called on download complete.
197 * @param progress_cb A callback called during the download operation.
198 * @param data User data passed to both callbacks.
199 * @param job_ret Job used to abort the download.
200 * @return EINA_TRUE if the download start or EINA_FALSE on failure
201 *
202 * This function starts the download of the URL @p url and saves it to
203 * @p dst. @p url must provide the protocol, including 'http://',
204 * 'ftp://' or 'file://'. Ecore_File must be compiled with CURL to
205 * download using http and ftp protocols. If @p dst is ill-formed, or
206 * if it already exists, the function returns EINA_FALSE. When the
207 * download is complete, the callback @p completion_cb is called and
208 * @p data is passed to it. The @p status parameter of @p completion_cb
209 * will be filled with the status of the download (200, 404,...). The
210 * @p progress_cb is called during the download operation, each time a
211 * packet is received or when CURL wants. It can be used to display the
212 * percentage of the downloaded file. Return 0 from this callback, if provided,
213 * to continue the operation or anything else to abort the download. The only
214 * operations that can be aborted are those with protocol 'http' or 'ftp'. In
215 * that case @p job_ret can be filled. It can be used with
216 * ecore_file_download_abort() or ecore_file_download_abort_all() to
217 * respectively abort one or all download operations. This function returns
218 * EINA_TRUE if the download starts, EINA_FALSE otherwise.
219 */
220EAPI Eina_Bool
221ecore_file_download(const char *url,
222 const char *dst,
223 Ecore_File_Download_Completion_Cb completion_cb,
224 Ecore_File_Download_Progress_Cb progress_cb,
225 void *data,
226 Ecore_File_Download_Job **job_ret)
227{
228 return _ecore_file_download(url, dst, completion_cb, progress_cb, data, job_ret, NULL);
229}
230
231/**
232 * @brief Download the given url to the given destination with additional headers.
233 *
234 * @param url The complete url to download.
235 * @param dst The local file to save the downloaded to.
236 * @param completion_cb A callback called on download complete.
237 * @param progress_cb A callback called during the download operation.
238 * @param data User data passed to both callbacks.
239 * @param job_ret Job used to abort the download.
240 * @param headers pointer of header lists.
241 * @return EINA_TRUE if the download start or EINA_FALSE on failure
242 */
243EAPI Eina_Bool
244ecore_file_download_full(const char *url,
245 const char *dst,
246 Ecore_File_Download_Completion_Cb completion_cb,
247 Ecore_File_Download_Progress_Cb progress_cb,
248 void *data,
249 Ecore_File_Download_Job **job_ret,
250 Eina_Hash *headers)
251{
252 return _ecore_file_download(url, dst, completion_cb, progress_cb, data, job_ret, headers);
253}
254
255/**
256 * @brief Check if the given protocol is available.
257 *
258 * @param protocol The protocol to check.
259 * @return EINA_TRUE if protocol is handled, EINA_FALSE otherwise.
260 *
261 * This function returns EINA_TRUE if @p protocol is supported,
262 * EINA_FALSE otherwise. @p protocol can be 'http://', 'ftp://' or
263 * 'file://'. Ecore_FILE must be compiled with CURL to handle http and
264 * ftp protocols.
265 */
266EAPI Eina_Bool
267ecore_file_download_protocol_available(const char *protocol)
268{
269#ifdef BUILD_ECORE_CON
270 if (!strncmp(protocol, "file://", 7)) return EINA_TRUE;
271# ifdef HAVE_CURL
272 else if (!strncmp(protocol, "http://", 7)) return EINA_TRUE;
273 else if (!strncmp(protocol, "ftp://", 6)) return EINA_TRUE;
274# endif
275#else
276 (void)protocol;
277#endif /* BUILD_ECORE_CON */
278
279 return EINA_FALSE;
280}
281
282#ifdef BUILD_ECORE_CON
283
284# ifdef HAVE_CURL
285static int
286_ecore_file_download_url_compare_job(const void *data1, const void *data2)
287{
288 const Ecore_File_Download_Job *job = data1;
289 const Ecore_Con_Url *url = data2;
290
291 if (job->url_con == url) return 0;
292 return -1;
293}
294
295static Eina_Bool
296_ecore_file_download_url_complete_cb(void *data __UNUSED__, int type __UNUSED__, void *event)
297{
298 Ecore_Con_Event_Url_Complete *ev = event;
299 Ecore_File_Download_Job *job;
300
301 job = eina_list_search_unsorted(_job_list, _ecore_file_download_url_compare_job, ev->url_con);
302 if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_FILE_DOWNLOAD_JOB)) return ECORE_CALLBACK_PASS_ON;
303
304 fclose(job->file);
305 if (job->completion_cb)
306 job->completion_cb(ecore_con_url_data_get(job->url_con), job->dst, ev->status);
307
308 _job_list = eina_list_remove(_job_list, job);
309 free(job->dst);
310 ecore_con_url_free(job->url_con);
311 free(job);
312
313 return ECORE_CALLBACK_DONE;
314}
315
316static Eina_Bool
317_ecore_file_download_url_progress_cb(void *data __UNUSED__, int type __UNUSED__, void *event)
318{
319/* this reports the downloads progress. if we return 0, then download
320 * continues, if we return anything else, then the download stops */
321 Ecore_Con_Event_Url_Progress *ev = event;
322 Ecore_File_Download_Job *job;
323
324 job = eina_list_search_unsorted(_job_list, _ecore_file_download_url_compare_job, ev->url_con);
325 if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_FILE_DOWNLOAD_JOB)) return ECORE_CALLBACK_PASS_ON;
326
327 if (job->progress_cb)
328 if (job->progress_cb(ecore_con_url_data_get(job->url_con), job->dst,
329 (long int) ev->down.total, (long int) ev->down.now,
330 (long int) ev->up.total, (long int) ev->up.now) != 0)
331 {
332 _job_list = eina_list_remove(_job_list, job);
333 fclose(job->file);
334 free(job->dst);
335 free(job);
336
337 return ECORE_CALLBACK_PASS_ON;
338 }
339
340 return ECORE_CALLBACK_DONE;
341}
342
343Ecore_File_Download_Job *
344_ecore_file_download_curl(const char *url, const char *dst,
345 Ecore_File_Download_Completion_Cb completion_cb,
346 Ecore_File_Download_Progress_Cb progress_cb,
347 void *data,
348 Eina_Hash *headers)
349{
350 Ecore_File_Download_Job *job;
351
352 job = calloc(1, sizeof(Ecore_File_Download_Job));
353 if (!job) return NULL;
354
355 ECORE_MAGIC_SET(job, ECORE_MAGIC_FILE_DOWNLOAD_JOB);
356
357 job->file = fopen(dst, "wb");
358 if (!job->file)
359 {
360 free(job);
361 return NULL;
362 }
363 job->url_con = ecore_con_url_new(url);
364 if (!job->url_con)
365 {
366 fclose(job->file);
367 free(job);
368 return NULL;
369 }
370
371 if (headers) eina_hash_foreach(headers, _ecore_file_download_headers_foreach_cb, job);
372 ecore_con_url_fd_set(job->url_con, fileno(job->file));
373 ecore_con_url_data_set(job->url_con, data);
374
375 job->dst = strdup(dst);
376
377 job->completion_cb = completion_cb;
378 job->progress_cb = progress_cb;
379 _job_list = eina_list_append(_job_list, job);
380
381 if (!ecore_con_url_get(job->url_con))
382 {
383 ecore_con_url_free(job->url_con);
384 _job_list = eina_list_remove(_job_list, job);
385 fclose(job->file);
386 ecore_file_remove(job->dst);
387 free(job->dst);
388 free(job);
389 return NULL;
390 }
391
392 return job;
393}
394# endif
395#endif
396
397/**
398 * @brief Abort the given download job and call the completion_cb
399 * callbck with a status of 1 (error).
400 *
401 * @param job The download job to abort.
402 *
403 * This function aborts a download operation started by
404 * ecore_file_download(). @p job is the #Ecore_File_Download_Job
405 * structure filled by ecore_file_download(). If it is @c NULL, this
406 * function does nothing. To abort all the currently downloading
407 * operations, call ecore_file_download_abort_all().
408 */
409EAPI void
410ecore_file_download_abort(Ecore_File_Download_Job *job)
411{
412 if (!job)
413 return;
414
415#ifdef BUILD_ECORE_CON
416 if (job->completion_cb)
417 job->completion_cb(ecore_con_url_data_get(job->url_con), job->dst, 1);
418# ifdef HAVE_CURL
419 ecore_con_url_free(job->url_con);
420# endif
421 _job_list = eina_list_remove(_job_list, job);
422 fclose(job->file);
423 free(job->dst);
424 free(job);
425#endif /* BUILD_ECORE_CON */
426}
427
428/**
429 * @brief Abort all downloads.
430 *
431 * This function aborts all the downloads that have been started by
432 * ecore_file_download(). It loops over the started downloads and call
433 * ecore_file_download_abort() for each of them. To abort only one
434 * specific download operation, call ecore_file_download_abort().
435 */
436EAPI void
437ecore_file_download_abort_all(void)
438{
439#ifdef BUILD_ECORE_CON
440 Ecore_File_Download_Job *job;
441
442 EINA_LIST_FREE(_job_list, job)
443 ecore_file_download_abort(job);
444#endif /* BUILD_ECORE_CON */
445}
446
447/**
448 * @}
449 */
diff --git a/libraries/ecore/src/lib/ecore_file/ecore_file_monitor.c b/libraries/ecore/src/lib/ecore_file/ecore_file_monitor.c
deleted file mode 100644
index 7c334c0..0000000
--- a/libraries/ecore/src/lib/ecore_file/ecore_file_monitor.c
+++ /dev/null
@@ -1,180 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ecore_file_private.h"
6
7typedef enum {
8 ECORE_FILE_MONITOR_TYPE_NONE,
9#ifdef HAVE_INOTIFY
10 ECORE_FILE_MONITOR_TYPE_INOTIFY,
11#endif
12#ifdef HAVE_NOTIFY_WIN32
13 ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32,
14#endif
15#ifdef HAVE_POLL
16 ECORE_FILE_MONITOR_TYPE_POLL
17#endif
18} Ecore_File_Monitor_Type;
19
20static Ecore_File_Monitor_Type monitor_type = ECORE_FILE_MONITOR_TYPE_NONE;
21
22int
23ecore_file_monitor_init(void)
24{
25#ifdef HAVE_INOTIFY
26 monitor_type = ECORE_FILE_MONITOR_TYPE_INOTIFY;
27 if (ecore_file_monitor_inotify_init())
28 return 1;
29#endif
30#ifdef HAVE_NOTIFY_WIN32
31 monitor_type = ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32;
32 if (ecore_file_monitor_win32_init())
33 return 1;
34#endif
35#ifdef HAVE_POLL
36 monitor_type = ECORE_FILE_MONITOR_TYPE_POLL;
37 if (ecore_file_monitor_poll_init())
38 return 1;
39#endif
40 monitor_type = ECORE_FILE_MONITOR_TYPE_NONE;
41 return 0;
42}
43
44void
45ecore_file_monitor_shutdown(void)
46{
47 switch (monitor_type)
48 {
49 case ECORE_FILE_MONITOR_TYPE_NONE:
50 break;
51#ifdef HAVE_INOTIFY
52 case ECORE_FILE_MONITOR_TYPE_INOTIFY:
53 ecore_file_monitor_inotify_shutdown();
54 break;
55#endif
56#ifdef HAVE_NOTIFY_WIN32
57 case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
58 ecore_file_monitor_win32_shutdown();
59 break;
60#endif
61#ifdef HAVE_POLL
62 case ECORE_FILE_MONITOR_TYPE_POLL:
63 ecore_file_monitor_poll_shutdown();
64 break;
65#endif
66 }
67}
68
69/**
70 * @addtogroup Ecore_File_Group Ecore_File - Files and directories convenience functions
71 *
72 * @{
73 */
74
75/**
76 * @brief Monitor the given path using inotify, Windows notification, or polling.
77 *
78 * @param path The path to monitor.
79 * @param func The function to call on changes.
80 * @param data The data passed to func.
81 * @return An Ecore_File_Monitor pointer or NULL on failure.
82 *
83 * This function monitors @p path. If @p path is @c NULL, or is an
84 * empty string, or none of the notify methods (Inotify, Windows
85 * notification or polling) is available, or if @p path is not a file,
86 * the function returns @c NULL. Otherwise, it returns a newly
87 * allocated Ecore_File_Monitor object and the monitoring begins. When
88 * one of the #Ecore_File_Event event is notified, @p func is called
89 * and @p data is passed to @p func. Call ecore_file_monitor_del() to
90 * stop the monitoring.
91 */
92EAPI Ecore_File_Monitor *
93ecore_file_monitor_add(const char *path,
94 Ecore_File_Monitor_Cb func,
95 void *data)
96{
97 if (!path || !*path)
98 return NULL;
99
100 switch (monitor_type)
101 {
102 case ECORE_FILE_MONITOR_TYPE_NONE:
103 return NULL;
104#ifdef HAVE_INOTIFY
105 case ECORE_FILE_MONITOR_TYPE_INOTIFY:
106 return ecore_file_monitor_inotify_add(path, func, data);
107#endif
108#ifdef HAVE_NOTIFY_WIN32
109 case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
110 return ecore_file_monitor_win32_add(path, func, data);
111#endif
112#ifdef HAVE_POLL
113 case ECORE_FILE_MONITOR_TYPE_POLL:
114 return ecore_file_monitor_poll_add(path, func, data);
115#endif
116 }
117 return NULL;
118}
119
120/**
121 * @brief Stop the monitoring of the given path.
122 *
123 * @param em The Ecore_File_Monitor to stop.
124 *
125 * This function stops the the monitoring of the path that has been
126 * monitored by ecore_file_monitor_add(). @p em must be the value
127 * returned by ecore_file_monitor_add(). If @p em is @c NULL, or none
128 * of the notify methods (Inotify, Windows notification or polling) is
129 * availablethis function does nothing.
130 */
131EAPI void
132ecore_file_monitor_del(Ecore_File_Monitor *em)
133{
134 if (!em)
135 return;
136
137 switch (monitor_type)
138 {
139 case ECORE_FILE_MONITOR_TYPE_NONE:
140 break;
141#ifdef HAVE_INOTIFY
142 case ECORE_FILE_MONITOR_TYPE_INOTIFY:
143 ecore_file_monitor_inotify_del(em);
144 break;
145#endif
146#ifdef HAVE_NOTIFY_WIN32
147 case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
148 ecore_file_monitor_win32_del(em);
149 break;
150#endif
151#ifdef HAVE_POLL
152 case ECORE_FILE_MONITOR_TYPE_POLL:
153 ecore_file_monitor_poll_del(em);
154 break;
155#endif
156 }
157}
158
159/**
160 * @brief Get the monitored path.
161 *
162 * @param em The Ecore_File_Monitor to query.
163 * @return The path that is monitored by @p em.
164 *
165 * This function returns the monitored path that has been
166 * monitored by ecore_file_monitor_add(). @p em must be the value
167 * returned by ecore_file_monitor_add(). If @p em is @c NULL, the
168 * function returns @c NULL.
169 */
170EAPI const char *
171ecore_file_monitor_path_get(Ecore_File_Monitor *em)
172{
173 if (!em)
174 return NULL;
175 return em->path;
176}
177
178/**
179 * @}
180 */
diff --git a/libraries/ecore/src/lib/ecore_file/ecore_file_monitor_inotify.c b/libraries/ecore/src/lib/ecore_file/ecore_file_monitor_inotify.c
deleted file mode 100644
index efdd8c2..0000000
--- a/libraries/ecore/src/lib/ecore_file/ecore_file_monitor_inotify.c
+++ /dev/null
@@ -1,370 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7#include <string.h>
8#include <sys/types.h>
9#include <unistd.h>
10
11#include "ecore_file_private.h"
12
13/*
14 * TODO:
15 *
16 * - Listen to these events:
17 * IN_ACCESS, IN_ATTRIB, IN_CLOSE_WRITE, IN_CLOSE_NOWRITE, IN_OPEN
18 * - Read all events first, then call the callbacks. This will prevent several
19 * callbacks with the typic save cycle (delete file, new file)
20 * - Listen to IN_IGNORED, emitted when the watch is removed
21 */
22
23#ifdef HAVE_INOTIFY
24
25#ifdef HAVE_SYS_INOTIFY
26# include <sys/inotify.h>
27#else
28# include <asm/unistd.h>
29# include <linux/inotify.h>
30#endif
31
32#ifndef HAVE_SYS_INOTIFY
33static inline int inotify_init(void);
34static inline int inotify_add_watch(int fd, const char *name, __u32 mask);
35static inline int inotify_rm_watch(int fd, __u32 wd);
36#endif
37
38
39typedef struct _Ecore_File_Monitor_Inotify Ecore_File_Monitor_Inotify;
40
41#define ECORE_FILE_MONITOR_INOTIFY(x) ((Ecore_File_Monitor_Inotify *)(x))
42
43struct _Ecore_File_Monitor_Inotify
44{
45 Ecore_File_Monitor monitor;
46 int wd;
47};
48
49static Ecore_Fd_Handler *_fdh = NULL;
50static Ecore_File_Monitor *_monitors = NULL;
51static pid_t _inotify_fd_pid = -1;
52
53static Eina_Bool _ecore_file_monitor_inotify_handler(void *data, Ecore_Fd_Handler *fdh);
54static Ecore_File_Monitor *_ecore_file_monitor_inotify_monitor_find(int wd);
55static void _ecore_file_monitor_inotify_events(Ecore_File_Monitor *em, char *file, int mask);
56static int _ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path);
57#if 0
58static void _ecore_file_monitor_inotify_print(char *file, int mask);
59#endif
60
61int
62ecore_file_monitor_inotify_init(void)
63{
64 int fd;
65
66 fd = inotify_init();
67 if (fd < 0)
68 return 0;
69
70 _fdh = ecore_main_fd_handler_add(fd, ECORE_FD_READ, _ecore_file_monitor_inotify_handler,
71 NULL, NULL, NULL);
72 if (!_fdh)
73 {
74 close(fd);
75 return 0;
76 }
77
78 _inotify_fd_pid = getpid();
79 return 1;
80}
81
82int
83ecore_file_monitor_inotify_shutdown(void)
84{
85 int fd;
86
87 while(_monitors)
88 ecore_file_monitor_inotify_del(_monitors);
89
90 if (_fdh)
91 {
92 fd = ecore_main_fd_handler_fd_get(_fdh);
93 ecore_main_fd_handler_del(_fdh);
94 close(fd);
95 }
96 _inotify_fd_pid = -1;
97 return 1;
98}
99
100Ecore_File_Monitor *
101ecore_file_monitor_inotify_add(const char *path,
102 void (*func) (void *data, Ecore_File_Monitor *em,
103 Ecore_File_Event event,
104 const char *path),
105 void *data)
106{
107 Ecore_File_Monitor *em;
108 int len;
109
110 if (_inotify_fd_pid == -1) return NULL;
111
112 if (_inotify_fd_pid != getpid())
113 {
114 ecore_file_monitor_inotify_shutdown();
115 ecore_file_monitor_inotify_init();
116 }
117
118 em = calloc(1, sizeof(Ecore_File_Monitor_Inotify));
119 if (!em) return NULL;
120
121 em->func = func;
122 em->data = data;
123
124 em->path = strdup(path);
125 len = strlen(em->path);
126 if (em->path[len - 1] == '/' && strcmp(em->path, "/"))
127 em->path[len - 1] = 0;
128
129 _monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
130
131 if (ecore_file_exists(em->path))
132 {
133 if (!_ecore_file_monitor_inotify_monitor(em, em->path))
134 return NULL;
135 }
136 else
137 {
138 ecore_file_monitor_inotify_del(em);
139 return NULL;
140 }
141
142 return em;
143}
144
145void
146ecore_file_monitor_inotify_del(Ecore_File_Monitor *em)
147{
148 int fd;
149
150 if (_monitors)
151 _monitors = ECORE_FILE_MONITOR(eina_inlist_remove(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
152
153 fd = ecore_main_fd_handler_fd_get(_fdh);
154 if (ECORE_FILE_MONITOR_INOTIFY(em)->wd)
155 inotify_rm_watch(fd, ECORE_FILE_MONITOR_INOTIFY(em)->wd);
156 free(em->path);
157 free(em);
158}
159
160static Eina_Bool
161_ecore_file_monitor_inotify_handler(void *data __UNUSED__, Ecore_Fd_Handler *fdh)
162{
163 Ecore_File_Monitor *em;
164 char buffer[16384];
165 struct inotify_event *event;
166 int i = 0;
167 int event_size;
168 ssize_t size;
169
170 size = read(ecore_main_fd_handler_fd_get(fdh), buffer, sizeof(buffer));
171 while (i < size)
172 {
173 event = (struct inotify_event *)&buffer[i];
174 event_size = sizeof(struct inotify_event) + event->len;
175 i += event_size;
176
177 em = _ecore_file_monitor_inotify_monitor_find(event->wd);
178 if (!em) continue;
179
180 _ecore_file_monitor_inotify_events(em, (event->len ? event->name : NULL), event->mask);
181 }
182
183 return ECORE_CALLBACK_RENEW;
184}
185
186static Ecore_File_Monitor *
187_ecore_file_monitor_inotify_monitor_find(int wd)
188{
189 Ecore_File_Monitor *l;
190
191 EINA_INLIST_FOREACH(_monitors, l)
192 {
193 if (ECORE_FILE_MONITOR_INOTIFY(l)->wd == wd)
194 return l;
195 }
196 return NULL;
197}
198
199static void
200_ecore_file_monitor_inotify_events(Ecore_File_Monitor *em, char *file, int mask)
201{
202 char buf[PATH_MAX];
203 int isdir;
204
205 if ((file) && (file[0]))
206 snprintf(buf, sizeof(buf), "%s/%s", em->path, file);
207 else
208 strcpy(buf, em->path);
209 isdir = mask & IN_ISDIR;
210
211#if 0
212 _ecore_file_monitor_inotify_print(buf, mask);
213#endif
214
215 if (mask & IN_ATTRIB)
216 {
217 em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, buf);
218 }
219 if (mask & IN_CLOSE_WRITE)
220 {
221 if (!isdir)
222 em->func(em->data, em, ECORE_FILE_EVENT_CLOSED, buf);
223 }
224 if (mask & IN_MODIFY)
225 {
226 if (!isdir)
227 em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, buf);
228 }
229 if (mask & IN_MOVED_FROM)
230 {
231 if (isdir)
232 em->func(em->data, em, ECORE_FILE_EVENT_DELETED_DIRECTORY, buf);
233 else
234 em->func(em->data, em, ECORE_FILE_EVENT_DELETED_FILE, buf);
235 }
236 if (mask & IN_MOVED_TO)
237 {
238 if (isdir)
239 em->func(em->data, em, ECORE_FILE_EVENT_CREATED_DIRECTORY, buf);
240 else
241 em->func(em->data, em, ECORE_FILE_EVENT_CREATED_FILE, buf);
242 }
243 if (mask & IN_DELETE)
244 {
245 if (isdir)
246 em->func(em->data, em, ECORE_FILE_EVENT_DELETED_DIRECTORY, buf);
247 else
248 em->func(em->data, em, ECORE_FILE_EVENT_DELETED_FILE, buf);
249 }
250 if (mask & IN_CREATE)
251 {
252 if (isdir)
253 em->func(em->data, em, ECORE_FILE_EVENT_CREATED_DIRECTORY, buf);
254 else
255 em->func(em->data, em, ECORE_FILE_EVENT_CREATED_FILE, buf);
256 }
257 if (mask & IN_DELETE_SELF)
258 {
259 em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
260 }
261 if (mask & IN_MOVE_SELF)
262 {
263 /* We just call delete. The dir is gone... */
264 em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
265 }
266 if (mask & IN_UNMOUNT)
267 {
268 /* We just call delete. The dir is gone... */
269 em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
270 }
271 if (mask & IN_IGNORED)
272 {
273 /* The watch is removed. If the file name still exists monitor the new one,
274 * else delete it */
275 if (ecore_file_exists(em->path))
276 {
277 if (!_ecore_file_monitor_inotify_monitor(em, em->path))
278 em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
279 }
280 else
281 em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
282 }
283}
284
285static int
286_ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path)
287{
288 int mask =
289 IN_ATTRIB |
290 IN_CLOSE_WRITE |
291 IN_MOVED_FROM |
292 IN_MOVED_TO |
293 IN_DELETE |
294 IN_CREATE |
295 IN_MODIFY |
296 IN_DELETE_SELF |
297 IN_MOVE_SELF |
298 IN_UNMOUNT;
299
300 ECORE_FILE_MONITOR_INOTIFY(em)->wd =
301 inotify_add_watch(ecore_main_fd_handler_fd_get(_fdh), path, mask);
302 if (ECORE_FILE_MONITOR_INOTIFY(em)->wd < 0)
303 {
304 ERR("inotify_add_watch error");
305 ecore_file_monitor_inotify_del(em);
306 return 0;
307 }
308 return 1;
309}
310
311#ifndef HAVE_SYS_INOTIFY
312static inline int
313inotify_init(void)
314{
315 return syscall(__NR_inotify_init);
316}
317
318static inline int
319inotify_add_watch(int fd, const char *name, __u32 mask)
320{
321 return syscall(__NR_inotify_add_watch, fd, name, mask);
322}
323
324static inline int
325inotify_rm_watch(int fd, __u32 wd)
326{
327 return syscall(__NR_inotify_rm_watch, fd, wd);
328}
329#endif
330
331#if 0
332static void
333_ecore_file_monitor_inotify_print(char *file, int mask)
334{
335 const char *type;
336
337 if (mask & IN_ISDIR)
338 type = "dir";
339 else
340 type = "file";
341
342 if (mask & IN_ACCESS)
343 INF("Inotify accessed %s: %s", type, file);
344 if (mask & IN_MODIFY)
345 INF("Inotify modified %s: %s", type, file);
346 if (mask & IN_ATTRIB)
347 INF("Inotify attributes %s: %s", type, file);
348 if (mask & IN_CLOSE_WRITE)
349 INF("Inotify close write %s: %s", type, file);
350 if (mask & IN_CLOSE_NOWRITE)
351 INF("Inotify close write %s: %s", type, file);
352 if (mask & IN_OPEN)
353 INF("Inotify open %s: %s", type, file);
354 if (mask & IN_MOVED_FROM)
355 INF("Inotify moved from %s: %s", type, file);
356 if (mask & IN_MOVED_TO)
357 INF("Inotify moved to %s: %s", type, file);
358 if (mask & IN_DELETE)
359 INF("Inotify delete %s: %s", type, file);
360 if (mask & IN_CREATE)
361 INF("Inotify create %s: %s", type, file);
362 if (mask & IN_DELETE_SELF)
363 INF("Inotify delete self %s: %s", type, file);
364 if (mask & IN_MOVE_SELF)
365 INF("Inotify move self %s: %s", type, file);
366 if (mask & IN_UNMOUNT)
367 INF("Inotify unmount %s: %s", type, file);
368}
369#endif
370#endif /* HAVE_INOTIFY */
diff --git a/libraries/ecore/src/lib/ecore_file/ecore_file_monitor_poll.c b/libraries/ecore/src/lib/ecore_file/ecore_file_monitor_poll.c
deleted file mode 100644
index 49bfcb6..0000000
--- a/libraries/ecore/src/lib/ecore_file/ecore_file_monitor_poll.c
+++ /dev/null
@@ -1,340 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7#include <string.h>
8
9#include "ecore_file_private.h"
10
11#ifdef HAVE_POLL
12
13/*
14 * TODO:
15 * - Implement recursive as an option!
16 * - Keep whole path or just name of file? (Memory or CPU...)
17 * - Remove requests without files?
18 * - Change poll time
19 */
20
21typedef struct _Ecore_File_Monitor_Poll Ecore_File_Monitor_Poll;
22
23#define ECORE_FILE_MONITOR_POLL(x) ((Ecore_File_Monitor_Poll *)(x))
24
25struct _Ecore_File_Monitor_Poll
26{
27 Ecore_File_Monitor monitor;
28 int mtime;
29 unsigned char deleted;
30};
31
32#define ECORE_FILE_INTERVAL_MIN 1.0
33#define ECORE_FILE_INTERVAL_STEP 0.5
34#define ECORE_FILE_INTERVAL_MAX 5.0
35
36static double _interval = ECORE_FILE_INTERVAL_MIN;
37static Ecore_Timer *_timer = NULL;
38static Ecore_File_Monitor *_monitors = NULL;
39static int _lock = 0;
40
41static Eina_Bool _ecore_file_monitor_poll_handler(void *data);
42static void _ecore_file_monitor_poll_check(Ecore_File_Monitor *em);
43static int _ecore_file_monitor_poll_checking(Ecore_File_Monitor *em, char *name);
44
45int
46ecore_file_monitor_poll_init(void)
47{
48 return 1;
49}
50
51int
52ecore_file_monitor_poll_shutdown(void)
53{
54 while(_monitors)
55 ecore_file_monitor_poll_del(_monitors);
56
57 if (_timer)
58 {
59 ecore_timer_del(_timer);
60 _timer = NULL;
61 }
62 return 1;
63}
64
65Ecore_File_Monitor *
66ecore_file_monitor_poll_add(const char *path,
67 void (*func) (void *data, Ecore_File_Monitor *em,
68 Ecore_File_Event event,
69 const char *path),
70 void *data)
71{
72 Ecore_File_Monitor *em;
73 size_t len;
74
75 if (!path) return NULL;
76 if (!func) return NULL;
77
78 em = calloc(1, sizeof(Ecore_File_Monitor_Poll));
79 if (!em) return NULL;
80
81 if (!_timer)
82 _timer = ecore_timer_add(_interval, _ecore_file_monitor_poll_handler, NULL);
83 else
84 ecore_timer_interval_set(_timer, ECORE_FILE_INTERVAL_MIN);
85
86 em->path = strdup(path);
87 len = strlen(em->path);
88 if (em->path[len - 1] == '/' && strcmp(em->path, "/"))
89 em->path[len - 1] = 0;
90
91 em->func = func;
92 em->data = data;
93
94 ECORE_FILE_MONITOR_POLL(em)->mtime = ecore_file_mod_time(em->path);
95 _monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
96
97 if (ecore_file_exists(em->path))
98 {
99 if (ecore_file_is_dir(em->path))
100 {
101 /* Check for subdirs */
102 Eina_List *files;
103 char *file;
104
105 files = ecore_file_ls(em->path);
106 EINA_LIST_FREE(files, file)
107 {
108 Ecore_File *f;
109 char buf[PATH_MAX];
110
111 f = calloc(1, sizeof(Ecore_File));
112 if (!f)
113 {
114 free(file);
115 continue;
116 }
117
118 snprintf(buf, sizeof(buf), "%s/%s", em->path, file);
119 f->name = file;
120 f->mtime = ecore_file_mod_time(buf);
121 f->is_dir = ecore_file_is_dir(buf);
122 em->files = (Ecore_File *) eina_inlist_append(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f));
123 }
124 }
125 }
126 else
127 {
128 ecore_file_monitor_poll_del(em);
129 return NULL;
130 }
131
132 return em;
133}
134
135void
136ecore_file_monitor_poll_del(Ecore_File_Monitor *em)
137{
138 Ecore_File *l;
139
140 if (_lock)
141 {
142 ECORE_FILE_MONITOR_POLL(em)->deleted = 1;
143 return;
144 }
145
146 /* Remove files */
147 /*It's possible there weren't any files to monitor, so check if the list is init*/
148 if (em->files)
149 {
150 for (l = em->files; l;)
151 {
152 Ecore_File *file = l;
153
154 l = (Ecore_File *) EINA_INLIST_GET(l)->next;
155 free(file->name);
156 free(file);
157 }
158 }
159
160 if (_monitors)
161 _monitors = ECORE_FILE_MONITOR(eina_inlist_remove(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
162
163 free(em->path);
164 free(em);
165
166 if (_timer)
167 {
168 if (!_monitors)
169 {
170 ecore_timer_del(_timer);
171 _timer = NULL;
172 }
173 else
174 ecore_timer_interval_set(_timer, ECORE_FILE_INTERVAL_MIN);
175 }
176}
177
178static Eina_Bool
179_ecore_file_monitor_poll_handler(void *data __UNUSED__)
180{
181 Ecore_File_Monitor *l;
182
183 _interval += ECORE_FILE_INTERVAL_STEP;
184
185 _lock = 1;
186 EINA_INLIST_FOREACH(_monitors, l)
187 _ecore_file_monitor_poll_check(l);
188 _lock = 0;
189
190 if (_interval > ECORE_FILE_INTERVAL_MAX)
191 _interval = ECORE_FILE_INTERVAL_MAX;
192 ecore_timer_interval_set(_timer, _interval);
193
194 for (l = _monitors; l;)
195 {
196 Ecore_File_Monitor *em = l;
197
198 l = ECORE_FILE_MONITOR(EINA_INLIST_GET(l)->next);
199 if (ECORE_FILE_MONITOR_POLL(em)->deleted)
200 ecore_file_monitor_del(em);
201 }
202 return ECORE_CALLBACK_RENEW;
203}
204
205static void
206_ecore_file_monitor_poll_check(Ecore_File_Monitor *em)
207{
208 int mtime;
209
210 mtime = ecore_file_mod_time(em->path);
211 if (mtime < ECORE_FILE_MONITOR_POLL(em)->mtime)
212 {
213 Ecore_File *l;
214 Ecore_File_Event event;
215
216 /* Notify all files deleted */
217 for (l = em->files; l;)
218 {
219 Ecore_File *f = l;
220 char buf[PATH_MAX];
221
222 l = (Ecore_File *) EINA_INLIST_GET(l)->next;
223
224 snprintf(buf, sizeof(buf), "%s/%s", em->path, f->name);
225 if (f->is_dir)
226 event = ECORE_FILE_EVENT_DELETED_DIRECTORY;
227 else
228 event = ECORE_FILE_EVENT_DELETED_FILE;
229 em->func(em->data, em, event, buf);
230 free(f->name);
231 free(f);
232 }
233 em->files = NULL;
234 em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
235 _interval = ECORE_FILE_INTERVAL_MIN;
236 }
237 else
238 {
239 Ecore_File *l;
240
241 /* Check for changed files */
242 for (l = em->files; l;)
243 {
244 Ecore_File *f = l;
245 char buf[PATH_MAX];
246 int mt;
247 Ecore_File_Event event;
248
249 l = (Ecore_File *) EINA_INLIST_GET(l)->next;
250
251 snprintf(buf, sizeof(buf), "%s/%s", em->path, f->name);
252 mt = ecore_file_mod_time(buf);
253 if (mt < f->mtime)
254 {
255 if (f->is_dir)
256 event = ECORE_FILE_EVENT_DELETED_DIRECTORY;
257 else
258 event = ECORE_FILE_EVENT_DELETED_FILE;
259
260 em->func(em->data, em, event, buf);
261 em->files = (Ecore_File *) eina_inlist_remove(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f));
262 free(f->name);
263 free(f);
264 _interval = ECORE_FILE_INTERVAL_MIN;
265 }
266 else if ((mt > f->mtime) && !(f->is_dir))
267 {
268 em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, buf);
269 _interval = ECORE_FILE_INTERVAL_MIN;
270 f->mtime = mt;
271 }
272 else
273 f->mtime = mt;
274 }
275
276 /* Check for new files */
277 if (ECORE_FILE_MONITOR_POLL(em)->mtime < mtime)
278 {
279 Eina_List *files;
280 Eina_List *fl;
281 char *file;
282
283 /* Files have been added or removed */
284 files = ecore_file_ls(em->path);
285 if (files)
286 {
287 /* Are we a directory? We should check first, rather than rely on null here*/
288 EINA_LIST_FOREACH(files, fl, file)
289 {
290 Ecore_File *f;
291 char buf[PATH_MAX];
292 Ecore_File_Event event;
293
294 if (_ecore_file_monitor_poll_checking(em, file))
295 continue;
296
297 snprintf(buf, sizeof(buf), "%s/%s", em->path, file);
298 f = calloc(1, sizeof(Ecore_File));
299 if (!f)
300 continue;
301
302 f->name = strdup(file);
303 f->mtime = ecore_file_mod_time(buf);
304 f->is_dir = ecore_file_is_dir(buf);
305 if (f->is_dir)
306 event = ECORE_FILE_EVENT_CREATED_DIRECTORY;
307 else
308 event = ECORE_FILE_EVENT_CREATED_FILE;
309 em->func(em->data, em, event, buf);
310 em->files = (Ecore_File *) eina_inlist_append(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f));
311 }
312 while (files)
313 {
314 file = eina_list_data_get(files);
315 free(file);
316 files = eina_list_remove_list(files, files);
317 }
318 }
319
320 if (!ecore_file_is_dir(em->path))
321 em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, em->path);
322 _interval = ECORE_FILE_INTERVAL_MIN;
323 }
324 }
325 ECORE_FILE_MONITOR_POLL(em)->mtime = mtime;
326}
327
328static int
329_ecore_file_monitor_poll_checking(Ecore_File_Monitor *em, char *name)
330{
331 Ecore_File *l;
332
333 EINA_INLIST_FOREACH(em->files, l)
334 {
335 if (!strcmp(l->name, name))
336 return 1;
337 }
338 return 0;
339}
340#endif
diff --git a/libraries/ecore/src/lib/ecore_file/ecore_file_monitor_win32.c b/libraries/ecore/src/lib/ecore_file/ecore_file_monitor_win32.c
deleted file mode 100644
index 7f3af09..0000000
--- a/libraries/ecore/src/lib/ecore_file/ecore_file_monitor_win32.c
+++ /dev/null
@@ -1,310 +0,0 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4
5#ifdef HAVE_CONFIG_H
6# include <config.h>
7#endif
8
9#ifdef HAVE_NOTIFY_WIN32
10
11# define WIN32_LEAN_AND_MEAN
12# include <windows.h>
13# undef WIN32_LEAN_AND_MEAN
14# include <process.h>
15
16# include "ecore_file_private.h"
17
18
19typedef struct _Ecore_File_Monitor_Win32 Ecore_File_Monitor_Win32;
20typedef struct _Ecore_File_Monitor_Win32_Data Ecore_File_Monitor_Win32_Data;
21
22/* 4096 = 256 * sizeof(FILE_NOTIFY_INFORMATION) */
23# define ECORE_FILE_MONITOR_WIN32_BUFFER_SIZE 4096
24# define ECORE_FILE_MONITOR_WIN32(x) ((Ecore_File_Monitor_Win32 *)(x))
25
26struct _Ecore_File_Monitor_Win32_Data
27{
28 char buffer[ECORE_FILE_MONITOR_WIN32_BUFFER_SIZE];
29 OVERLAPPED overlapped;
30 HANDLE handle;
31 HANDLE event;
32 Ecore_File_Monitor *monitor;
33 Ecore_Win32_Handler *h;
34 DWORD buf_length;
35 int is_dir;
36};
37
38struct _Ecore_File_Monitor_Win32
39{
40 Ecore_File_Monitor monitor;
41 Ecore_File_Monitor_Win32_Data *file;
42 Ecore_File_Monitor_Win32_Data *dir;
43};
44
45static Ecore_File_Monitor *_monitors = NULL;
46
47static Eina_Bool _ecore_file_monitor_win32_cb(void *data, Ecore_Win32_Handler *wh);
48
49
50static Ecore_File_Monitor_Win32_Data *
51_ecore_file_monitor_win32_data_new(Ecore_File_Monitor *monitor, int type)
52{
53 Ecore_File_Monitor_Win32_Data *md;
54 DWORD filter;
55
56 md = (Ecore_File_Monitor_Win32_Data *)calloc(1, sizeof(Ecore_File_Monitor_Win32_Data));
57 if (!md) return NULL;
58
59 md->handle = CreateFile(monitor->path,
60 FILE_LIST_DIRECTORY,
61 FILE_SHARE_READ |
62 FILE_SHARE_WRITE,
63 NULL,
64 OPEN_EXISTING,
65 FILE_FLAG_BACKUP_SEMANTICS |
66 FILE_FLAG_OVERLAPPED,
67 NULL);
68 if (md->handle == INVALID_HANDLE_VALUE)
69 goto free_md;
70
71 md->event = CreateEvent(NULL, FALSE, FALSE, NULL);
72 if (!md->event)
73 goto close_handle;
74
75 ZeroMemory (&md->overlapped, sizeof(md->overlapped));
76 md->overlapped.hEvent = md->event;
77
78 filter = (type == 0) ? FILE_NOTIFY_CHANGE_FILE_NAME : FILE_NOTIFY_CHANGE_DIR_NAME;
79 filter |=
80 FILE_NOTIFY_CHANGE_ATTRIBUTES |
81 FILE_NOTIFY_CHANGE_SIZE |
82 FILE_NOTIFY_CHANGE_LAST_WRITE |
83 FILE_NOTIFY_CHANGE_LAST_ACCESS |
84 FILE_NOTIFY_CHANGE_CREATION |
85 FILE_NOTIFY_CHANGE_SECURITY;
86
87 if (!ReadDirectoryChangesW(md->handle,
88 md->buffer,
89 ECORE_FILE_MONITOR_WIN32_BUFFER_SIZE,
90 FALSE,
91 filter,
92 &md->buf_length,
93 &md->overlapped,
94 NULL))
95 goto close_event;
96
97 md->h = ecore_main_win32_handler_add(md->event,
98 _ecore_file_monitor_win32_cb,
99 md);
100 if (!md->h)
101 goto close_event;
102
103 md->monitor = monitor;
104 md->is_dir = type;
105
106 return md;
107
108 close_event:
109 CloseHandle(md->event);
110 close_handle:
111 CloseHandle(md->handle);
112 free_md:
113 free(md);
114
115 return NULL;
116}
117
118static void
119_ecore_file_monitor_win32_data_free(Ecore_File_Monitor_Win32_Data *md)
120{
121 if (!md) return;
122
123 CloseHandle(md->event);
124 CloseHandle (md->handle);
125 free (md);
126}
127
128static Eina_Bool
129_ecore_file_monitor_win32_cb(void *data, Ecore_Win32_Handler *wh)
130{
131 char filename[PATH_MAX];
132 PFILE_NOTIFY_INFORMATION fni;
133 Ecore_File_Monitor_Win32_Data *md;
134 wchar_t *wname;
135 char *name;
136 DWORD filter;
137 DWORD offset;
138 DWORD buf_length;
139 Ecore_File_Event event = ECORE_FILE_EVENT_NONE;
140
141 md = (Ecore_File_Monitor_Win32_Data *)data;
142
143 if (!GetOverlappedResult (md->handle, &md->overlapped, &buf_length, TRUE))
144 return 1;
145
146 fni = (PFILE_NOTIFY_INFORMATION)md->buffer;
147 do {
148 if (!fni)
149 break;
150 offset = fni->NextEntryOffset;
151
152 wname = (wchar_t *)malloc(sizeof(wchar_t) * (fni->FileNameLength + 1));
153 if (!wname)
154 return 0;
155
156 memcpy(wname, fni->FileName, fni->FileNameLength);
157 wname[fni->FileNameLength]='\0';
158 name = evil_wchar_to_char(wname);
159 free(wname);
160 if (!name)
161 return 0;
162
163 _snprintf(filename, PATH_MAX, "%s\\%s", md->monitor->path, name);
164 free(name);
165
166 switch (fni->Action)
167 {
168 case FILE_ACTION_ADDED:
169 if (md->is_dir)
170 event = ECORE_FILE_EVENT_CREATED_DIRECTORY;
171 else
172 event = ECORE_FILE_EVENT_CREATED_FILE;
173 break;
174 case FILE_ACTION_REMOVED:
175 if (md->is_dir)
176 event = ECORE_FILE_EVENT_DELETED_DIRECTORY;
177 else
178 event = ECORE_FILE_EVENT_DELETED_FILE;
179 break;
180 case FILE_ACTION_MODIFIED:
181 if (!md->is_dir)
182 event = ECORE_FILE_EVENT_MODIFIED;
183 break;
184 case FILE_ACTION_RENAMED_OLD_NAME:
185 if (md->is_dir)
186 event = ECORE_FILE_EVENT_DELETED_DIRECTORY;
187 else
188 event = ECORE_FILE_EVENT_DELETED_FILE;
189 break;
190 case FILE_ACTION_RENAMED_NEW_NAME:
191 if (md->is_dir)
192 event = ECORE_FILE_EVENT_CREATED_DIRECTORY;
193 else
194 event = ECORE_FILE_EVENT_CREATED_FILE;
195 break;
196 default:
197 fprintf(stderr, "unknown event\n");
198 event = ECORE_FILE_EVENT_NONE;
199 break;
200 }
201 if (event != ECORE_FILE_EVENT_NONE)
202 md->monitor->func(md->monitor->data, md->monitor, event, filename);
203
204 fni = (PFILE_NOTIFY_INFORMATION)((LPBYTE)fni + offset);
205 } while (offset);
206
207 filter = (md->is_dir == 0) ? FILE_NOTIFY_CHANGE_FILE_NAME : FILE_NOTIFY_CHANGE_DIR_NAME;
208 filter |=
209 FILE_NOTIFY_CHANGE_ATTRIBUTES |
210 FILE_NOTIFY_CHANGE_SIZE |
211 FILE_NOTIFY_CHANGE_LAST_WRITE |
212 FILE_NOTIFY_CHANGE_LAST_ACCESS |
213 FILE_NOTIFY_CHANGE_CREATION |
214 FILE_NOTIFY_CHANGE_SECURITY;
215
216 ReadDirectoryChangesW(md->handle,
217 md->buffer,
218 ECORE_FILE_MONITOR_WIN32_BUFFER_SIZE,
219 FALSE,
220 filter,
221 &md->buf_length,
222 &md->overlapped,
223 NULL);
224 return 1;
225}
226
227int
228ecore_file_monitor_win32_init(void)
229{
230 return 1;
231}
232
233int
234ecore_file_monitor_win32_shutdown(void)
235{
236 return 1;
237}
238
239Ecore_File_Monitor *
240ecore_file_monitor_win32_add(const char *path,
241 void (*func) (void *data, Ecore_File_Monitor *em,
242 Ecore_File_Event event,
243 const char *path),
244 void *data)
245{
246 Ecore_File_Monitor_Win32 *m;
247 Ecore_File_Monitor *em;
248 size_t len;
249
250 if (!path || (*path == '\0')) return NULL;
251 if (!ecore_file_exists(path) || !ecore_file_is_dir(path))
252 return NULL;
253 if (!func) return NULL;
254
255 em = (Ecore_File_Monitor *)calloc(1, sizeof(Ecore_File_Monitor_Win32));
256 if (!em) return NULL;
257
258 em->func = func;
259 em->data = data;
260
261 em->path = strdup(path);
262 if (!em->path)
263 {
264 free(em);
265 return NULL;
266 }
267 len = strlen(em->path);
268 if (em->path[len - 1] == '/' || em->path[len - 1] == '\\')
269 em->path[len - 1] = '\0';
270
271 m = ECORE_FILE_MONITOR_WIN32(em);
272
273 m->file = _ecore_file_monitor_win32_data_new(em, 0);
274 if (!m->file)
275 {
276 free(em->path);
277 free(em);
278 return NULL;
279 }
280
281 m->dir = _ecore_file_monitor_win32_data_new(em, 1);
282 if (!m->dir)
283 {
284 _ecore_file_monitor_win32_data_free(m->file);
285 free(em->path);
286 free(em);
287 return NULL;
288 }
289
290 _monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
291
292 return em;
293}
294
295void
296ecore_file_monitor_win32_del(Ecore_File_Monitor *em)
297{
298 Ecore_File_Monitor_Win32 *m;
299
300 if (!em)
301 return;
302
303 m = ECORE_FILE_MONITOR_WIN32(em);
304 _ecore_file_monitor_win32_data_free(m->dir);
305 _ecore_file_monitor_win32_data_free(m->file);
306 free(em->path);
307 free(em);
308}
309
310#endif
diff --git a/libraries/ecore/src/lib/ecore_file/ecore_file_path.c b/libraries/ecore/src/lib/ecore_file/ecore_file_path.c
deleted file mode 100644
index f5294b7..0000000
--- a/libraries/ecore/src/lib/ecore_file/ecore_file_path.c
+++ /dev/null
@@ -1,185 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#undef alloca
6#ifdef HAVE_ALLOCA_H
7# include <alloca.h>
8#elif defined __GNUC__
9# define alloca __builtin_alloca
10#elif defined _AIX
11# define alloca __alloca
12#elif defined _MSC_VER
13# include <malloc.h>
14# define alloca _alloca
15#else
16# include <stddef.h>
17# ifdef __cplusplus
18extern "C"
19# endif
20void *alloca (size_t);
21#endif
22
23#include <stdlib.h>
24#include <stdio.h>
25#include <string.h>
26
27#include "ecore_file_private.h"
28
29static Eina_List *__ecore_file_path_bin = NULL;
30
31static Eina_List *_ecore_file_path_from_env(const char *env);
32
33void
34ecore_file_path_init(void)
35{
36 __ecore_file_path_bin = _ecore_file_path_from_env("PATH");
37}
38
39void
40ecore_file_path_shutdown(void)
41{
42 char *dir;
43
44 EINA_LIST_FREE(__ecore_file_path_bin, dir)
45 eina_stringshare_del(dir);
46}
47
48Eina_List *
49_ecore_file_path_from_env(const char *env)
50{
51 Eina_List *path = NULL;
52 char *env_tmp, *env_path, *p, *last;
53
54 env_tmp = getenv(env);
55 if (!env_tmp)
56 return path;
57
58 env_path = alloca(sizeof(char) * strlen(env_tmp) + 1);
59 memset(env_path, 0, strlen(env_tmp));
60 strcpy(env_path, env_tmp);
61 last = env_path;
62 for (p = env_path; *p; p++)
63 {
64 if (*p == ':')
65 *p = '\0';
66
67 if (!*p)
68 {
69 if (!ecore_file_path_dir_exists(last))
70 path = eina_list_append(path, eina_stringshare_add(last));
71 last = p + 1;
72 }
73 }
74 if (p > last)
75 path = eina_list_append(path, eina_stringshare_add(last));
76
77 return path;
78}
79
80/**
81 * @addtogroup Ecore_File_Group Ecore_File - Files and directories convenience functions
82 *
83 * @{
84 */
85
86/**
87 * @brief Check if the given directory is in PATH.
88 *
89 * @param in_dir The name of the directory to search in PATH.
90 * @return EINA_TRUE if the directory exist in PATH, EINA_FALSE otherwise.
91 *
92 * This function checks if @p in_dir is in the environment variable
93 * PATH. If @p in_dir is @c NULL, or if PATH is empty, or @p in_dir is
94 * not in PATH, the function returns EINA_FALSE, otherwise it returns
95 * EINA_TRUE.
96 */
97EAPI Eina_Bool
98ecore_file_path_dir_exists(const char *in_dir)
99{
100 Eina_List *l;
101 char *dir;
102
103 if (!in_dir)
104 return EINA_FALSE;
105
106 if (!__ecore_file_path_bin) return EINA_FALSE;
107 EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir)
108 {
109 if (strcmp(dir, in_dir))
110 return EINA_TRUE;
111 }
112
113 return EINA_FALSE;
114}
115
116/**
117 * @brief Check if the given application is installed.
118 *
119 * @param exe The name of the application
120 * @return EINA_TRUE if the exe is in PATH and is executable,
121 * EINA_FALSE otherwise.
122 *
123 *
124 * This function checks if @p exe exists in PATH and is executable. If
125 * @p exe is @c NULL or is not executable, the function returns
126 * EINA_FALSE, otherwise it returns EINA_TRUE.
127 */
128EAPI Eina_Bool
129ecore_file_app_installed(const char *exe)
130{
131 Eina_List *l;
132 char *dir;
133 char buf[PATH_MAX];
134
135 if (!exe) return EINA_FALSE;
136 if (ecore_file_can_exec(exe)) return EINA_TRUE;
137
138 EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir)
139 {
140 snprintf(buf, sizeof(buf), "%s/%s", dir, exe);
141 if (ecore_file_can_exec(buf))
142 return EINA_TRUE;
143 }
144
145 return EINA_FALSE;
146}
147
148/**
149 * @brief Get a list of all the applications installed on the system.
150 *
151 * @return An Eina_List containing all the executable files in the
152 * system.
153 *
154 * This function returns a list of allocated strings of all the
155 * executable files. If no files are found, the function returns
156 * @c NULL. When not needed anymore, the element of the list must be
157 * freed.
158 */
159EAPI Eina_List *
160ecore_file_app_list(void)
161{
162 Eina_List *list = NULL;
163 Eina_List *files;
164 Eina_List *l;
165 char buf[PATH_MAX], *dir, *exe;
166
167 EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir)
168 {
169 files = ecore_file_ls(dir);
170 EINA_LIST_FREE(files, exe)
171 {
172 snprintf(buf, sizeof(buf), "%s/%s", dir, exe);
173 if ((ecore_file_can_exec(buf)) &&
174 (!ecore_file_is_dir(buf)))
175 list = eina_list_append(list, strdup(buf));
176 free(exe);
177 }
178 }
179
180 return list;
181}
182
183/**
184 * @}
185 */
diff --git a/libraries/ecore/src/lib/ecore_file/ecore_file_private.h b/libraries/ecore/src/lib/ecore_file/ecore_file_private.h
deleted file mode 100644
index 45d2cbd..0000000
--- a/libraries/ecore/src/lib/ecore_file/ecore_file_private.h
+++ /dev/null
@@ -1,129 +0,0 @@
1#ifndef ECORE_FILE_PRIVATE_H_
2#define ECORE_FILE_PRIVATE_H_
3
4#ifdef __linux__
5# include <features.h>
6#endif
7
8#ifdef HAVE_EVIL
9# include <Evil.h>
10#endif
11
12#ifdef HAVE_ESCAPE
13# include <Escape.h>
14#endif
15
16#include <sys/types.h>
17#include <sys/stat.h>
18
19#include "Ecore.h"
20#include "ecore_private.h"
21
22#include "Ecore_File.h"
23
24extern int _ecore_file_log_dom;
25
26#ifdef ECORE_FILE_DEFAULT_LOG_COLOR
27#undef ECORE_FILE_DEFAULT_LOG_COLOR
28#endif
29#define ECORE_FILE_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
30
31#ifdef ERR
32# undef ERR
33#endif
34#define ERR(...) EINA_LOG_DOM_ERR(_ecore_file_log_dom, __VA_ARGS__)
35
36#ifdef DBG
37# undef DBG
38#endif
39#define DBG(...) EINA_LOG_DOM_DBG(_ecore_file_log_dom, __VA_ARGS__)
40
41#ifdef INF
42# undef INF
43#endif
44#define INF(...) EINA_LOG_DOM_INFO(_ecore_file_log_dom, __VA_ARGS__)
45
46#ifdef WRN
47# undef WRN
48#endif
49#define WRN(...) EINA_LOG_DOM_WARN(_ecore_file_log_dom, __VA_ARGS__)
50
51#ifdef CRIT
52# undef CRIT
53#endif
54#define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_file_log_dom, __VA_ARGS__)
55
56/* ecore_file_monitor */
57int ecore_file_monitor_init(void);
58void ecore_file_monitor_shutdown(void);
59
60#define ECORE_FILE_MONITOR(x) ((Ecore_File_Monitor *)(x))
61
62typedef struct _Ecore_File Ecore_File;
63struct _Ecore_File
64{
65 EINA_INLIST;
66 char *name;
67 int mtime;
68 unsigned char is_dir;
69};
70
71struct _Ecore_File_Monitor
72{
73 EINA_INLIST;
74 void (*func) (void *data,
75 Ecore_File_Monitor *ecore_file_monitor,
76 Ecore_File_Event event,
77 const char *path);
78
79 char *path;
80 void *data;
81 Ecore_File *files;
82};
83
84#ifdef HAVE_INOTIFY
85int ecore_file_monitor_inotify_init(void);
86int ecore_file_monitor_inotify_shutdown(void);
87Ecore_File_Monitor *ecore_file_monitor_inotify_add(const char *path,
88 void (*func) (void *data,
89 Ecore_File_Monitor *ecore_file_monitor,
90 Ecore_File_Event event,
91 const char *path),
92 void *data);
93void ecore_file_monitor_inotify_del(Ecore_File_Monitor *ecore_file_monitor);
94#endif
95
96#ifdef HAVE_NOTIFY_WIN32
97int ecore_file_monitor_win32_init(void);
98int ecore_file_monitor_win32_shutdown(void);
99Ecore_File_Monitor *ecore_file_monitor_win32_add(const char *path,
100 void (*func) (void *data,
101 Ecore_File_Monitor *ecore_file_monitor,
102 Ecore_File_Event event,
103 const char *path),
104 void *data);
105void ecore_file_monitor_win32_del(Ecore_File_Monitor *ecore_file_monitor);
106#endif
107
108#ifdef HAVE_POLL
109int ecore_file_monitor_poll_init(void);
110int ecore_file_monitor_poll_shutdown(void);
111Ecore_File_Monitor *ecore_file_monitor_poll_add(const char *path,
112 void (*func) (void *data,
113 Ecore_File_Monitor *ecore_file_monitor,
114 Ecore_File_Event event,
115 const char *path),
116 void *data);
117void ecore_file_monitor_poll_del(Ecore_File_Monitor *ecore_file_monitor);
118
119#endif
120
121/* ecore_file_path */
122void ecore_file_path_init(void);
123void ecore_file_path_shutdown(void);
124
125/* ecore_file_download */
126int ecore_file_download_init(void);
127void ecore_file_download_shutdown(void);
128
129#endif