summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2016-04-12 16:00:23 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2016-05-23 21:15:02 -0300
commite2dcc136b38c662a32ab9ab9d4d6fe6854399289 (patch)
tree2116d1ae33849a8eccbd2e6cbdee621b76dfba6d
parent1775fe18761127a7fa39a8098369c13fa5938ae6 (diff)
Adds Eo-based Eio api and moves the current Eio to legacy.devs/felipealmeida/eio-eo
The legacy Eio_File factory functions are replaced by an Eo object called Eo_Job that return promises wrapping the async file operations. With this commit, the legacy Eio callbacks are replaced by the following Eo/Promises counterparts : * Done_Cb -> Promise then success callback * Error_Cb -> Promise then error callback * Main_Cb -> Promise progress callback * Filter_Cb -> Job object event (more below) Events are used to deliver and get the filter data. To differentiate between the named and direct versions, they come in "filter,direct" and "filter,name" versions. Monitors were wrapped inside a new class Eo_Sentry. The user creates a sentry object and adds monitoring targets to it, listening to events on it. The sentry event info is composed of two strings. The source string is the path being monitored, i.e. the one passed to eio_sentry_add, and the trigger string is the path that actually triggered the event, e.g. a new file created in a monitored directory. Eina mmap and Eet-related functions are not (yet?) supported.
-rw-r--r--src/Makefile_Eio.am24
-rw-r--r--src/examples/eio/Makefile.am44
-rw-r--r--src/examples/eio/eio_job_ls.c79
-rw-r--r--src/examples/eio/eio_job_open.c80
-rw-r--r--src/examples/eio/eio_job_open_multi.c103
-rw-r--r--src/examples/eio/eio_sentry.c55
-rw-r--r--src/lib/eio/Eio.h1260
-rw-r--r--src/lib/eio/Eio_Eo.h13
-rw-r--r--src/lib/eio/Eio_Legacy.h1256
-rw-r--r--src/lib/eio/eio_job.c586
-rw-r--r--src/lib/eio/eio_job.eo152
-rw-r--r--src/lib/eio/eio_job_private.h12
-rw-r--r--src/lib/eio/eio_sentry.c166
-rw-r--r--src/lib/eio/eio_sentry.eo49
-rw-r--r--src/lib/eio/eio_sentry_private.h13
-rw-r--r--src/lib/eo/eina_types.eot8
-rw-r--r--src/tests/eio/eio_suite.c3
-rw-r--r--src/tests/eio/eio_suite.h3
-rw-r--r--src/tests/eio/eio_test_common.c89
-rw-r--r--src/tests/eio/eio_test_common.h16
-rw-r--r--src/tests/eio/eio_test_file.c72
-rw-r--r--src/tests/eio/eio_test_job.c287
-rw-r--r--src/tests/eio/eio_test_job_xattr.c204
-rw-r--r--src/tests/eio/eio_test_sentry.c755
-rw-r--r--src/tests/eio/eio_test_xattr.c17
25 files changed, 3993 insertions, 1353 deletions
diff --git a/src/Makefile_Eio.am b/src/Makefile_Eio.am
index 64b7972e81..f234f3e075 100644
--- a/src/Makefile_Eio.am
+++ b/src/Makefile_Eio.am
@@ -2,7 +2,9 @@
2### Library 2### Library
3 3
4eio_eolian_files = \ 4eio_eolian_files = \
5 lib/eio/eio_model.eo 5 lib/eio/eio_model.eo \
6 lib/eio/eio_job.eo \
7 lib/eio/eio_sentry.eo
6 8
7eio_eolian_h = $(eio_eolian_files:%.eo=%.eo.h) 9eio_eolian_h = $(eio_eolian_files:%.eo=%.eo.h)
8eio_eolian_c = $(eio_eolian_files:%.eo=%.eo.c) 10eio_eolian_c = $(eio_eolian_files:%.eo=%.eo.c)
@@ -20,13 +22,19 @@ lib/eio/Makefile.in
20 22
21installed_eiomainheadersdir = $(includedir)/eio-@VMAJ@ 23installed_eiomainheadersdir = $(includedir)/eio-@VMAJ@
22 24
23dist_installed_eiomainheaders_DATA = lib/eio/Eio.h lib/eio/eio_inline_helper.x 25dist_installed_eiomainheaders_DATA = \
26lib/eio/Eio.h \
27lib/eio/Eio_Legacy.h \
28lib/eio/Eio_Eo.h \
29lib/eio/eio_inline_helper.x
24nodist_installed_eiomainheaders_DATA = $(eio_eoolian_h) 30nodist_installed_eiomainheaders_DATA = $(eio_eoolian_h)
25 31
26lib_eio_libeio_la_SOURCES = \ 32lib_eio_libeio_la_SOURCES = \
27lib/eio/eio_dir.c \ 33lib/eio/eio_dir.c \
28lib/eio/eio_eet.c \ 34lib/eio/eio_eet.c \
29lib/eio/eio_file.c \ 35lib/eio/eio_file.c \
36lib/eio/eio_job.c \
37lib/eio/eio_sentry.c \
30lib/eio/eio_main.c \ 38lib/eio/eio_main.c \
31lib/eio/eio_map.c \ 39lib/eio/eio_map.c \
32lib/eio/eio_monitor.c \ 40lib/eio/eio_monitor.c \
@@ -62,13 +70,6 @@ if HAVE_NOTIFY_COCOA
62lib_eio_libeio_la_LDFLAGS += -framework CoreServices 70lib_eio_libeio_la_LDFLAGS += -framework CoreServices
63endif 71endif
64 72
65if HAVE_CXX11
66
67eio_eolian_cxx_hh = $(eio_eolian_files:%.eo=%.eo.hh)
68eio_eolian_cxx_impl = $(eio_eolian_files:%.eo=%.eo.impl.hh)
69
70endif
71
72if EFL_ENABLE_TESTS 73if EFL_ENABLE_TESTS
73 74
74check_PROGRAMS += tests/eio/eio_suite 75check_PROGRAMS += tests/eio/eio_suite
@@ -79,8 +80,13 @@ tests/eio/eio_suite.c \
79tests/eio/eio_model_test_file.c \ 80tests/eio/eio_model_test_file.c \
80tests/eio/eio_model_test_monitor_add.c \ 81tests/eio/eio_model_test_monitor_add.c \
81tests/eio/eio_test_monitor.c \ 82tests/eio/eio_test_monitor.c \
83tests/eio/eio_test_sentry.c \
82tests/eio/eio_test_file.c \ 84tests/eio/eio_test_file.c \
85tests/eio/eio_test_job.c \
86tests/eio/eio_test_job_xattr.c \
83tests/eio/eio_test_xattr.c \ 87tests/eio/eio_test_xattr.c \
88tests/eio/eio_test_common.c \
89tests/eio/eio_test_common.h \
84tests/eio/eio_suite.h 90tests/eio/eio_suite.h
85 91
86tests_eio_eio_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ 92tests_eio_eio_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
diff --git a/src/examples/eio/Makefile.am b/src/examples/eio/Makefile.am
index 53b95fec48..4fccc70310 100644
--- a/src/examples/eio/Makefile.am
+++ b/src/examples/eio/Makefile.am
@@ -24,31 +24,53 @@ endif
24 24
25EXTRA_PROGRAMS = \ 25EXTRA_PROGRAMS = \
26eio_file_ls \ 26eio_file_ls \
27eio_file_copy 27eio_file_copy \
28eio_job_open \
29eio_job_open_multi \
30eio_job_ls \
31eio_sentry
28 32
29eio_file_ls_SOURCES = eio_file_ls.c 33EIO_EXAMPLES_LDADD = \
30eio_file_ls_LDADD = \
31$(top_builddir)/src/lib/eio/libeio.la \ 34$(top_builddir)/src/lib/eio/libeio.la \
32$(top_builddir)/src/lib/eo/libeo.la \ 35$(top_builddir)/src/lib/eo/libeo.la \
33$(top_builddir)/src/lib/ecore/libecore.la \ 36$(top_builddir)/src/lib/ecore/libecore.la \
37$(top_builddir)/src/lib/efl/libefl.la \
34$(top_builddir)/src/lib/eet/libeet.la \ 38$(top_builddir)/src/lib/eet/libeet.la \
35$(top_builddir)/src/lib/emile/libemile.la \ 39$(top_builddir)/src/lib/emile/libemile.la \
36$(top_builddir)/src/lib/eina/libeina.la \ 40$(top_builddir)/src/lib/eina/libeina.la \
37@EIO_LDFLAGS@ 41@EIO_LDFLAGS@
38 42
43eio_file_ls_SOURCES = eio_file_ls.c
44eio_file_ls_LDADD = \
45$(EIO_EXAMPLES_LDADD)
46
39eio_file_copy_SOURCES = eio_file_copy.c 47eio_file_copy_SOURCES = eio_file_copy.c
40eio_file_copy_LDADD = \ 48eio_file_copy_LDADD = \
41$(top_builddir)/src/lib/eio/libeio.la \ 49$(EIO_EXAMPLES_LDADD)
42$(top_builddir)/src/lib/eo/libeo.la \ 50
43$(top_builddir)/src/lib/ecore/libecore.la \ 51eio_job_open_SOURCES = eio_job_open.c
44$(top_builddir)/src/lib/eet/libeet.la \ 52eio_job_open_LDADD = \
45$(top_builddir)/src/lib/emile/libemile.la \ 53$(EIO_EXAMPLES_LDADD)
46$(top_builddir)/src/lib/eina/libeina.la \ 54
47@EIO_LDFLAGS@ 55eio_job_open_multi_SOURCES = eio_job_open_multi.c
56eio_job_open_multi_LDADD = \
57$(EIO_EXAMPLES_LDADD)
58
59eio_job_ls_SOURCES = eio_job_ls.c
60eio_job_ls_LDADD = \
61$(EIO_EXAMPLES_LDADD)
62
63eio_sentry_SOURCES = eio_sentry.c
64eio_sentry_LDADD = \
65$(EIO_EXAMPLES_LDADD)
48 66
49SRCS = \ 67SRCS = \
50eio_file_ls.c \ 68eio_file_ls.c \
51eio_file_copy.c 69eio_file_copy.c \
70eio_job_open.c \
71eio_job_open_multi.c \
72eio_job_ls.c \
73eio_sentry.c
52 74
53DATA_FILES = Makefile.examples 75DATA_FILES = Makefile.examples
54 76
diff --git a/src/examples/eio/eio_job_ls.c b/src/examples/eio/eio_job_ls.c
new file mode 100644
index 0000000000..354325e4f8
--- /dev/null
+++ b/src/examples/eio/eio_job_ls.c
@@ -0,0 +1,79 @@
1#if HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5
6#include <stdlib.h>
7#include <stdio.h>
8
9#include <Eina.h>
10#include <Eio.h>
11#include <Ecore.h>
12
13void done_cb(void *data, void *value EINA_UNUSED)
14{
15 Eio_Job *job = data;
16 printf("%s done listing files.\n", __FUNCTION__);
17 ecore_main_loop_quit();
18 eo_unref(job);
19}
20
21void error_cb(void *data, Eina_Error *error)
22{
23 Eio_Job *job = data;
24 EINA_SAFETY_ON_NULL_RETURN(error);
25 const char *msg = eina_error_msg_get(*error);
26 printf("%s error: %s\n", __FUNCTION__, msg);
27 ecore_main_loop_quit();
28
29 eo_unref(job);
30}
31
32void filter_cb(void *data, const Eo_Event *event)
33{
34 Eio_Filter_Name_Data *event_info = event->info;
35 static Eina_Bool should_filter = EINA_FALSE;
36
37 printf("Filtering file %s\n", event_info->file);
38
39 should_filter = !should_filter;
40 event_info->filter = should_filter;
41}
42
43// Progress used to be the "Eio_Main_Cb" family of callbacks in the legacy API.
44void progress_cb(void *data, const char *filename)
45{
46 EINA_SAFETY_ON_NULL_RETURN(filename);
47 printf("%s listing filename: %s\n", __FUNCTION__, filename);
48}
49
50void list_files(void *data)
51{
52 Eina_Promise *promise;
53 const char *path = data;
54
55 Eio_Job *job = eo_add(EIO_JOB_CLASS, NULL);
56 eo_event_callback_add(job, EIO_JOB_EVENT_FILTER_NAME, (Eo_Event_Cb)&filter_cb, NULL);
57 eio_job_file_ls(job, path, &promise);
58 eina_promise_progress_cb_add(promise, (Eina_Promise_Progress_Cb)&progress_cb, NULL, NULL);
59 eina_promise_then(promise, (Eina_Promise_Cb)&done_cb, (Eina_Promise_Error_Cb)&error_cb, job);
60}
61
62int main(int argc, char const *argv[])
63{
64 eio_init();
65 ecore_init();
66
67 const char *path = getenv("HOME");
68
69 if (argc > 1)
70 path = argv[1];
71
72 Ecore_Job *job = ecore_job_add(&list_files, path);
73
74 ecore_main_loop_begin();
75
76 ecore_shutdown();
77 eio_shutdown();
78 return 0;
79}
diff --git a/src/examples/eio/eio_job_open.c b/src/examples/eio/eio_job_open.c
new file mode 100644
index 0000000000..fb235c2e06
--- /dev/null
+++ b/src/examples/eio/eio_job_open.c
@@ -0,0 +1,80 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include <Eina.h>
9#include <Eio.h>
10#include <Ecore.h>
11
12void error_cb(void *data, Eina_Error *error)
13{
14 EINA_SAFETY_ON_NULL_RETURN(error);
15 EINA_SAFETY_ON_NULL_RETURN(data);
16
17 const char *msg = eina_error_msg_get(*error);
18 EINA_LOG_ERR("error: %s", msg);
19
20 ecore_main_loop_quit();
21}
22
23void done_closing_cb(int *result EINA_UNUSED)
24{
25 printf("%s closed file.\n", __FUNCTION__);
26
27 ecore_main_loop_quit();
28}
29
30void closing_job(Eio_Job *job, Eina_File *file)
31{
32 Eina_Promise *promise = NULL;
33 printf("%s Will close the file...\n", __FUNCTION__);
34 eio_job_file_close(job, file, &promise);
35 eina_promise_then(promise, (Eina_Promise_Cb)&done_closing_cb, (Eina_Promise_Error_Cb)&error_cb, job);
36}
37
38void done_open_cb(void *data, Eina_File **file)
39{
40 EINA_SAFETY_ON_NULL_RETURN(data);
41 EINA_SAFETY_ON_NULL_RETURN(file);
42 EINA_SAFETY_ON_NULL_RETURN(*file);
43
44 Eio_Job *job = data;
45
46 const char *name = eina_file_filename_get(*file);
47 printf("%s opened file %s\n", __FUNCTION__, name);
48
49 closing_job(job, *file);
50}
51
52void open_file(const char *path)
53{
54 Eina_Promise *promise;
55
56 Eio_Job *job = eo_add(EIO_JOB_CLASS, NULL);
57 eio_job_file_open(job, path, EINA_FALSE, &promise);
58 eina_promise_then(promise, (Eina_Promise_Cb)&done_open_cb, (Eina_Promise_Error_Cb)&error_cb, job);
59
60 eo_unref(job);
61}
62
63int main(int argc, char const *argv[])
64{
65 eio_init();
66 ecore_init();
67
68 const char *path = getenv("HOME");
69
70 if (argc > 1)
71 path = argv[1];
72
73 open_file(path);
74
75 ecore_main_loop_begin();
76
77 ecore_shutdown();
78 eio_shutdown();
79 return 0;
80}
diff --git a/src/examples/eio/eio_job_open_multi.c b/src/examples/eio/eio_job_open_multi.c
new file mode 100644
index 0000000000..8082d4bfac
--- /dev/null
+++ b/src/examples/eio/eio_job_open_multi.c
@@ -0,0 +1,103 @@
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include <Eina.h>
9#include <Eio.h>
10#include <Ecore.h>
11
12void error_cb(void *data, Eina_Error *error)
13{
14 EINA_SAFETY_ON_NULL_RETURN(error);
15 EINA_SAFETY_ON_NULL_RETURN(data);
16
17 const char *msg = eina_error_msg_get(*error);
18 EINA_LOG_ERR("error: %s", msg);
19
20 Eio_Job *job = data;
21 eo_unref(job);
22
23 ecore_main_loop_quit();
24}
25
26void done_closing_cb(void *data, Eina_Iterator **result EINA_UNUSED)
27{
28 EINA_SAFETY_ON_NULL_RETURN(data);
29
30 printf("%s closed file.\n", __FUNCTION__);
31
32 Eio_Job *job = data;
33 eo_unref(job);
34
35 ecore_main_loop_quit();
36}
37
38void closing_job(Eio_Job *job, Eina_File *file1, Eina_File *file2)
39{
40 Eina_Promise *promise;
41 Eina_Promise *tasks[3] = {NULL, NULL, NULL};
42
43 printf("%s Closing files.\n", __FUNCTION__);
44 eio_job_file_close(job, file1, &tasks[0]);
45 eio_job_file_close(job, file2, &tasks[1]);
46 promise = eina_promise_all(eina_carray_iterator_new((void**)&tasks[0]));
47 eina_promise_then(promise, (Eina_Promise_Cb)&done_closing_cb, (Eina_Promise_Error_Cb)&error_cb, job);
48}
49
50void done_open_cb(void *data, Eina_Iterator **iterator)
51{
52 EINA_SAFETY_ON_NULL_RETURN(data);
53 EINA_SAFETY_ON_NULL_RETURN(iterator);
54 EINA_SAFETY_ON_NULL_RETURN(*iterator);
55 Eio_Job *job = data;
56
57 Eina_File **file = NULL;
58 Eina_File **files = calloc(sizeof(Eina_File*),2);
59 int i = 0;
60 while (eina_iterator_next(*iterator, (void**)&file))
61 {
62 files[i] = *file;
63 const char *name = eina_file_filename_get(*file);
64 printf("%s opened file %s\n", __FUNCTION__, name);
65 i++;
66 }
67 closing_job(job, files[0], files[1]);
68 free(files);
69}
70
71void open_file(const char *path, const char *path2)
72{
73 Eina_Promise *promise;
74 Eina_Promise *tasks[3] = {NULL, NULL, NULL};
75
76 Eio_Job *job = eo_add(EIO_JOB_CLASS, NULL);
77 eio_job_file_open(job, path, EINA_FALSE, &tasks[0]);
78 eio_job_file_open(job, path2, EINA_FALSE, &tasks[1]);
79 promise = eina_promise_all(eina_carray_iterator_new((void**)&tasks[0]));
80 eina_promise_then(promise, (Eina_Promise_Cb)&done_open_cb, (Eina_Promise_Error_Cb)&error_cb, job);
81}
82
83int main(int argc, char const *argv[])
84{
85 eio_init();
86 ecore_init();
87
88 const char *path = getenv("HOME");
89 const char *path2 = "./";
90
91 if (argc > 1)
92 path = argv[1];
93 if (argc > 2)
94 path2 = argv[2];
95
96 open_file(path, path2);
97
98 ecore_main_loop_begin();
99
100 ecore_shutdown();
101 eio_shutdown();
102 return 0;
103}
diff --git a/src/examples/eio/eio_sentry.c b/src/examples/eio/eio_sentry.c
new file mode 100644
index 0000000000..a6218a79e1
--- /dev/null
+++ b/src/examples/eio/eio_sentry.c
@@ -0,0 +1,55 @@
1#if HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5
6#include <stdlib.h>
7#include <stdio.h>
8
9#include <Eina.h>
10#include <Eio.h>
11#include <Ecore.h>
12
13Eina_Bool
14sentry_cb(void *data, const Eo_Event *event)
15{
16 Eio_Sentry_Event *event_info = event->info;
17
18 printf("Event on monitored path %s", event_info->source);
19 printf("Created file %s\n", event_info->trigger);
20
21 ecore_main_loop_quit();
22
23 return EINA_FALSE;
24}
25
26void
27monitor_stuff(void *data)
28{
29 const char *path = data;
30 Eio_Sentry *sentry = eo_add(EIO_SENTRY_CLASS, NULL);
31 eo_event_callback_add(sentry, EIO_SENTRY_EVENT_FILE_CREATED, (Eo_Event_Cb)&sentry_cb, NULL);
32
33 printf("Starting monitoring path %s\n", path);
34 eio_sentry_add(sentry, path);
35}
36
37int
38main(int argc, char const *argv[])
39{
40 eio_init();
41 ecore_init();
42
43 const char *path = getenv("HOME");
44
45 if (argc > 1)
46 path = argv[1];
47
48 Ecore_Job *job = ecore_job_add(&monitor_stuff, path);
49
50 ecore_main_loop_begin();
51
52 ecore_shutdown();
53 eio_shutdown();
54 return 0;
55}
diff --git a/src/lib/eio/Eio.h b/src/lib/eio/Eio.h
index 7ee29fe52a..16000f27ce 100644
--- a/src/lib/eio/Eio.h
+++ b/src/lib/eio/Eio.h
@@ -63,884 +63,12 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#define EIO_VERSION_MAJOR EFL_VERSION_MAJOR 66#ifndef EFL_NOLEGACY_API_SUPPORT
67#define EIO_VERSION_MINOR EFL_VERSION_MINOR 67#include "Eio_Legacy.h"
68 68#endif
69 /** 69#ifdef EFL_EO_API_SUPPORT
70 * @typedef Eio_Version 70#include "Eio_Eo.h"
71 * Represents the current version of EIO 71#endif
72 */
73 typedef struct _Eio_Version
74 {
75 int major; /**< Major version number */
76 int minor; /**< Minor version number */
77 int micro; /**< Micro version number */
78 int revision; /**< Revision number */
79 } Eio_Version;
80
81 EAPI extern Eio_Version *eio_version;
82
83/**
84 * @file
85 * @brief Eio asynchronous input/output library
86 *
87 * These routines are used for Eio.
88 */
89
90/**
91 * @page eio_main Eio
92 *
93 * @date 2012 (created)
94 *
95 * @section toc Table of Contents
96 *
97 * @li @ref eio_main_intro
98 * @li @ref eio_main_compiling
99 * @li @ref eio_main_next_steps
100 * @li @ref eio_main_intro_example
101 *
102 * @section eio_main_intro Introduction
103 *
104 * The Eio library is a library that implements an API for asynchronous
105 * input/output operation. Most operations are done in a separate thread
106 * to prevent lock. See @ref Eio_Group. Some helper to work on data
107 * received in Eio callback are also provided see @ref Eio_Helper.
108 * It is also possible to work asynchronously on Eina_File with @ref Eio_Map
109 * or on Eet_File with @ref Eio_Eet. It comes with way to manipulate
110 * eXtended attribute asynchronous with @ref Eio_Xattr.
111 *
112 * This library is cross-platform and can be compiled and used on
113 * Linux, BSD, Opensolaris and Windows (XP and CE). It is heavily
114 * based on @ref Ecore_Main_Loop_Group.
115 *
116 * @section eio_main_compiling How to compile
117 *
118 * Eio is a library your application links to. The procedure for this is
119 * very simple. You simply have to compile your application with the
120 * appropriate compiler flags that the @c pkg-config script outputs. For
121 * example:
122 *
123 * Compiling C or C++ files into object files:
124 *
125 * @verbatim
126 gcc -c -o main.o main.c `pkg-config --cflags eio`
127 @endverbatim
128 *
129 * Linking object files into a binary executable:
130 *
131 * @verbatim
132 gcc -o my_application main.o `pkg-config --libs eio`
133 @endverbatim
134 *
135 * See @ref pkgconfig
136 *
137 * @section eio_main_next_steps Next Steps
138 *
139 * After you understand what Eio is and installed it on your system
140 * you should proceed understand the programming interface.
141 *
142 * Recommended reading:
143 *
144 * @li @ref Eio_Helper for common functions and library initialization.
145 * @li @ref Eio_List for listing files asynchronous.
146 * @li @ref Eio_Management for anyone who want to do a file manager (copy, rm, ...).
147 * @li @ref Eio_Map to manipulate files asynchronously (mmap).
148 * @li @ref Eio_Xattr to access file extended attributes (xattr).
149 * @li @ref Eio_Monitor to monitor for file changes (inotify).
150 * @li @ref Eio_Eet to access Eet files asynchronously.
151 *
152 * @section eio_main_intro_example Introductory Example
153 *
154 * @include eio_file_ls.c
155 *
156 * More examples can be found at @ref eio_examples.
157 *
158 */
159
160/**
161 * @enum _Eio_File_Op
162 *
163 * @brief Input/Output operations on files.
164 *
165 * This enum represents the operations that can be done.
166 */
167enum _Eio_File_Op
168{
169 EIO_FILE_COPY, /**< I/O operation is about a specific file copy */
170 EIO_FILE_MOVE, /**< I/O operation is about a specific file move */
171 EIO_DIR_COPY, /**< I/O operation is about a specific directory copy */
172 EIO_DIR_MOVE, /**< I/O operation is about a specific directory move */
173 /** I/O operation is about destroying a path:
174 * source will point to base path to be destroyed,
175 * and dest will point to to path destroyed by this I/O
176 */
177 EIO_UNLINK,
178 EIO_FILE_GETPWNAM, /**< I/O operation is trying to get uid from user name */
179 EIO_FILE_GETGRNAM /**< I/O operation is trying to get gid from user name */
180};
181
182/**
183 * @typedef Eio_File_Op
184 * Input/Output operations on files.
185 */
186typedef enum _Eio_File_Op Eio_File_Op;
187
188/**
189 * @defgroup Eio_List Eio file listing API
190 * @ingroup Eio
191 *
192 * @brief This functions helps list files asynchronously.
193 *
194 * This set of functions work on top of Eina_File and Ecore_Thread
195 * to list files under various condition.
196 *
197 * @{
198 */
199
200/**
201 * @typedef Eio_File
202 * Generic asynchronous I/O reference.
203 */
204typedef struct _Eio_File Eio_File;
205
206/**
207 * @typedef Eio_Progress
208 * Progress information on a specific operation.
209 */
210typedef struct _Eio_Progress Eio_Progress;
211
212typedef Eina_Bool (*Eio_Filter_Cb)(void *data, Eio_File *handler, const char *file);
213typedef void (*Eio_Main_Cb)(void *data, Eio_File *handler, const char *file);
214
215typedef Eina_Bool (*Eio_Filter_Direct_Cb)(void *data, Eio_File *handler, const Eina_File_Direct_Info *info);
216typedef Eina_Bool (*Eio_Filter_Dir_Cb)(void *data, Eio_File *handler, Eina_File_Direct_Info *info);
217typedef void (*Eio_Main_Direct_Cb)(void *data, Eio_File *handler, const Eina_File_Direct_Info *info);
218
219typedef void (*Eio_Stat_Cb)(void *data, Eio_File *handler, const Eina_Stat *stat);
220typedef void (*Eio_Progress_Cb)(void *data, Eio_File *handler, const Eio_Progress *info);
221
222typedef void (*Eio_Eet_Open_Cb)(void *data, Eio_File *handler, Eet_File *file);
223typedef void (*Eio_Open_Cb)(void *data, Eio_File *handler, Eina_File *file);
224typedef Eina_Bool (*Eio_Filter_Map_Cb)(void *data, Eio_File *handler, void *map, size_t length);
225typedef void (*Eio_Map_Cb)(void *data, Eio_File *handler, void *map, size_t length);
226
227typedef void (*Eio_Done_Data_Cb)(void *data, Eio_File *handler, const char *read_data, unsigned int size);
228typedef void (*Eio_Done_String_Cb)(void *data, Eio_File *handler, const char *xattr_string);
229typedef void (*Eio_Done_Double_Cb)(void *data, Eio_File *handler, double xattr_double);
230typedef void (*Eio_Done_Int_Cb)(void *data, Eio_File *handler, int i);
231
232typedef void (*Eio_Done_ERead_Cb)(void *data, Eio_File *handler, void *decoded);
233typedef void (*Eio_Done_Read_Cb)(void *data, Eio_File *handler, void *read_data, unsigned int size);
234typedef void (*Eio_Done_Cb)(void *data, Eio_File *handler);
235typedef void (*Eio_Error_Cb)(void *data, Eio_File *handler, int error);
236typedef void (*Eio_Eet_Error_Cb)(void *data, Eio_File *handler, Eet_Error err);
237
238/**
239 * @struct _Eio_Progress
240 * @brief Represents the current progress of the operation.
241 */
242struct _Eio_Progress
243{
244 Eio_File_Op op; /**< I/O type */
245
246 long long current; /**< Current step in the I/O operation */
247 long long max; /**< Number of total steps to complete this I/O */
248 float percent; /**< Percent done for the I/O operation */
249
250 const char *source; /**< source of the I/O operation */
251 const char *dest; /**< target of the I/O operation */
252};
253
254/**
255 * @brief List contents of a directory without locking your app.
256 * @param dir The directory to list.
257 * @param filter_cb Callback used to decide if the file will be passed to main_cb
258 * @param main_cb Callback called for each listed file if it was not filtered.
259 * @param done_cb Callback called when the ls operation is done.
260 * @param error_cb Callback called when either the directory could not be opened or the operation has been canceled.
261 * @param data Unmodified user data passed to callbacks
262 * @return A reference to the I/O operation.
263 *
264 * This function is responsible for listing the content of a directory without blocking your application.
265 * It's equivalent to the "ls" shell command. Every file will be passed to the
266 * filter_cb, so it's your job to decide if you want to pass the file to the
267 * main_cb or not. Return EINA_TRUE to pass it to the main_cb or EINA_FALSE to
268 * ignore it. It runs eina_file_ls() in a separate thread using
269 * ecore_thread_feedback_run().
270 *
271 * @see eina_file_ls()
272 * @see ecore_thread_feedback_run()
273 * @see eio_file_direct_ls()
274 * @see eio_file_stat_ls()
275 */
276EAPI Eio_File *eio_file_ls(const char *dir,
277 Eio_Filter_Cb filter_cb,
278 Eio_Main_Cb main_cb,
279 Eio_Done_Cb done_cb,
280 Eio_Error_Cb error_cb,
281 const void *data);
282
283/**
284 * @brief List contents of a directory without locking your app.
285 * @param dir The directory to list.
286 * @param filter_cb Callback used to decide if the file will be passed to main_cb
287 * @param main_cb Callback called from the main loop for each accepted file (not filtered).
288 * @param done_cb Callback called from the main loop after the contents of the directory has been listed.
289 * @param error_cb Callback called from the main loop when either the directory could not be opened or the operation has been canceled.
290 * @param data Unmodified user data passed to callbacks
291 * @return A reference to the I/O operation.
292 *
293 * eio_file_direct_ls() runs eina_file_direct_ls() in a separate thread using
294 * ecore_thread_feedback_run(). This prevents any blocking in your apps.
295 * Every file will be passed to the filter_cb, so it's your job to decide if you
296 * want to pass the file to the main_cb or not. Return EINA_TRUE to pass it to
297 * the main_cb or EINA_FALSE to ignore it.
298 *
299 * @warning If readdir_r doesn't contain file type information, file type is
300 * EINA_FILE_UNKNOWN.
301 *
302 * @note The iterator walks over '.' and '..' without returning them.
303 * @note The difference between this function and eina_file_stat_ls() is that
304 * it may not get the file type information however it is likely to be
305 * faster.
306 *
307 * @see eio_file_stat_ls()
308 * @see eina_file_direct_ls()
309 * @see ecore_thread_feedback_run()
310 */
311EAPI Eio_File *eio_file_direct_ls(const char *dir,
312 Eio_Filter_Direct_Cb filter_cb,
313 Eio_Main_Direct_Cb main_cb,
314 Eio_Done_Cb done_cb,
315 Eio_Error_Cb error_cb,
316 const void *data);
317
318/**
319 * @brief List content of a directory without locking your app.
320 * @param dir The directory to list.
321 * @param filter_cb Callback used to decide if the file will be passed to main_cb
322 * @param main_cb Callback called from the main loop for each accepted file (not filtered).
323 * @param done_cb Callback called from the main loop after the contents of the directory has been listed.
324 * @param error_cb Callback called from the main loop when either the directory could not be opened or the operation has been canceled.
325 * @param data Unmodified user data passed to callbacks
326 * @return A reference to the I/O operation.
327 *
328 * Every file will be passed to the filter_cb, so it's your job to decide if you
329 * want to pass the file to the main_cb or not. Return EINA_TRUE to pass it to
330 * the main_cb or EINA_FALSE to ignore it. eio_file_stat_ls() run eina_file_stat_ls()
331 * in a separate thread using ecore_thread_feedback_run().
332 *
333 * @note The iterator walks over '.' and '..' without returning them.
334 * @note The difference between this function and eio_file_direct_ls() is that
335 * it guarantees the file type information to be correct by incurring a
336 * possible performance penalty.
337 *
338 * @see eio_file_stat_ls()
339 * @see eina_file_stat_ls()
340 * @see ecore_thread_feedback_run()
341 */
342EAPI Eio_File *eio_file_stat_ls(const char *dir,
343 Eio_Filter_Direct_Cb filter_cb,
344 Eio_Main_Direct_Cb main_cb,
345 Eio_Done_Cb done_cb,
346 Eio_Error_Cb error_cb,
347 const void *data);
348
349/**
350 * @brief List the content of a directory and all its sub-content asynchronously
351 * @param dir The directory to list.
352 * @param filter_cb Callback used to decide if the file will be passed to main_cb
353 * @param main_cb Callback called from the main loop for each accepted file (not filtered).
354 * @param done_cb Callback called from the main loop after the contents of the directory has been listed.
355 * @param error_cb Callback called from the main loop when either the directory could not be opened or the operation has been canceled.
356 * @param data Unmodified user data passed to callbacks
357 * @return A reference to the I/O operation.
358 *
359 * eio_dir_stat_ls() runs eina_file_stat_ls() recursively in a separate thread using
360 * ecore_thread_feedback_run(). This prevents any blocking in your apps.
361 * Every file will be passed to the
362 * filter_cb, so it's your job to decide if you want to pass the file to the
363 * main_cb or not. Return EINA_TRUE to pass it to the main_cb or EINA_FALSE to
364 * ignore it.
365 *
366 * @see eio_file_stat_ls()
367 * @see eio_dir_direct_ls()
368 * @see eina_file_stat_ls()
369 * @see ecore_thread_feedback_run()
370 */
371EAPI Eio_File *eio_dir_stat_ls(const char *dir,
372 Eio_Filter_Direct_Cb filter_cb,
373 Eio_Main_Direct_Cb main_cb,
374 Eio_Done_Cb done_cb,
375 Eio_Error_Cb error_cb,
376 const void *data);
377
378/**
379 * @brief List the content of a directory and all its sub-content asynchronously
380 * @param dir The directory to list.
381 * @param filter_cb Callback used to decide if the file will be passed to main_cb
382 * @param main_cb Callback called from the main loop for each accepted file (not filtered).
383 * @param done_cb Callback called from the main loop after the contents of the directory has been listed.
384 * @param error_cb Callback called from the main loop when either the directory could not be opened or the operation has been canceled.
385 * @param data Unmodified user data passed to callbacks
386 * @return A reference to the I/O operation.
387 *
388 * eio_dir_direct_ls() runs eina_file_direct_ls() recursively in a separate thread using
389 * ecore_thread_feedback_run(). This prevents any blocking in your apps.
390 * Every file will be passed to the filter_cb, so it's your job to decide if you
391 * want to pass the file to the main_cb or not. Return EINA_TRUE to pass it to
392 * the main_cb or EINA_FALSE to ignore it.
393 *
394 * @see eio_file_direct_ls()
395 * @see eio_dir_stat_ls()
396 * @see eina_file_direct_ls()
397 * @see ecore_thread_feedback_run()
398 */
399EAPI Eio_File *eio_dir_direct_ls(const char *dir,
400 Eio_Filter_Dir_Cb filter_cb,
401 Eio_Main_Direct_Cb main_cb,
402 Eio_Done_Cb done_cb,
403 Eio_Error_Cb error_cb,
404 const void *data);
405
406/**
407 * @brief Stat a file/directory.
408 * @param path The path to stat.
409 * @param done_cb Callback called from the main loop when stat was successfully called.
410 * @param error_cb Callback called from the main loop when stat failed or has been canceled.
411 * @param data Unmodified user data passed to callbacks
412 * @return A reference to the I/O operation.
413 *
414 * eio_file_direct_stat calls stat in another thread. This prevents any blocking in your apps.
415 */
416EAPI Eio_File *eio_file_direct_stat(const char *path,
417 Eio_Stat_Cb done_cb,
418 Eio_Error_Cb error_cb,
419 const void *data);
420
421/**
422 * @}
423 */
424
425/**
426 * @defgroup Eio_Management Eio file management API.
427 *
428 * @brief A set of function to manage file asynchronously.
429 *
430 * The function provided by this API are the one useful for any
431 * file manager. Like moving or copying a file, unlinking it, changing
432 * it's access right, ...
433 *
434 * @{
435 */
436
437/**
438 * @brief Change rights of a path.
439 * @param path The directory path to change access rights.
440 * @param mode The permission to set, follow (mode & ~umask & 0777).
441 * @param done_cb Callback called when the operation is completed.
442 * @param error_cb Callback called from if something goes wrong.
443 * @param data Unmodified user data passed to callbacks.
444 * @return A reference to the I/O operation.
445 *
446 * Set a new permission of a path changing it to the mode passed as argument.
447 * It's equivalent to the chmod command.
448 */
449EAPI Eio_File *eio_file_chmod(const char *path,
450 mode_t mode,
451 Eio_Done_Cb done_cb,
452 Eio_Error_Cb error_cb,
453 const void *data);
454
455/**
456 * @brief Change owner of a path.
457 * @param path The directory path to change owner.
458 * @param user The new user to set (can be NULL).
459 * @param group The new group to set (can be NULL).
460 * @param done_cb Callback called when the operation is completed.
461 * @param error_cb Callback called from if something goes wrong.
462 * @param data Unmodified user data passed to callbacks
463 * @return A reference to the I/O operation.
464 *
465 * This function will change the owner of a path, setting it to the user and
466 * group passed as argument. It's equivalent to the chown shell command.
467 */
468EAPI Eio_File *eio_file_chown(const char *path,
469 const char *user,
470 const char *group,
471 Eio_Done_Cb done_cb,
472 Eio_Error_Cb error_cb,
473 const void *data);
474
475/**
476 * @brief Unlink a file/directory.
477 * @param path The path to unlink.
478 * @param done_cb Callback called when the operation is completed.
479 * @param error_cb Callback called from if something goes wrong.
480 * @param data Unmodified user data passed to callbacks.
481 * @return A reference to the I/O operation.
482 *
483 * This function will erase a file.
484 */
485EAPI Eio_File *eio_file_unlink(const char *path,
486 Eio_Done_Cb done_cb,
487 Eio_Error_Cb error_cb,
488 const void *data);
489
490/**
491 * @brief Create a new directory.
492 * @param path The directory path to create.
493 * @param mode The permission to set, follow (mode & ~umask & 0777).
494 * @param done_cb Callback called when the operation is completed.
495 * @param error_cb Callback called from if something goes wrong.
496 * @param data Unmodified user data passed to callbacks
497 * @return A reference to the I/O operation.
498 *
499 * Creates a new directory using the mode provided.
500 */
501EAPI Eio_File *eio_file_mkdir(const char *path,
502 mode_t mode,
503 Eio_Done_Cb done_cb,
504 Eio_Error_Cb error_cb,
505 const void *data);
506
507/**
508 * @brief Move a file asynchronously
509 * @param source Should be the name of the file to move the data from.
510 * @param dest Should be the name of the file to move the data to.
511 * @param progress_cb Callback called to know the progress of the move.
512 * @param done_cb Callback called when the move is done.
513 * @param error_cb Callback called when something goes wrong.
514 * @param data Unmodified user data passed to callbacks
515 * @return A reference to the I/O operation.
516 *
517 * @return an Eio_File pointer, handler to the move operation, can be used to cancel the operation
518 *
519 * This function will copy a file from source to dest. It will try to use splice
520 * if possible, if not it will fallback to mmap/write. It will try to preserve
521 * access rights, but not user/group identification.
522 */
523EAPI Eio_File *eio_file_move(const char *source,
524 const char *dest,
525 Eio_Progress_Cb progress_cb,
526 Eio_Done_Cb done_cb,
527 Eio_Error_Cb error_cb,
528 const void *data);
529
530/**
531 * @brief Copy a file asynchronously
532 * @param source Should be the name of the file to copy the data from.
533 * @param dest Should be the name of the file to copy the data to.
534 * @param progress_cb Callback called to know the progress of the copy.
535 * @param done_cb Callback called when the copy is done.
536 * @param error_cb Callback called when something goes wrong.
537 * @param data Unmodified user data passed to callbacks
538 *
539 * @return an Eio_File pointer, handler to the copy operation, can be used to cancel the operation
540 *
541 * This function will copy a file from source to dest. It will try to use splice
542 * if possible, if not it will fallback to mmap/write. It will try to preserve
543 * access rights, but not user/group identification.
544 */
545EAPI Eio_File *eio_file_copy(const char *source,
546 const char *dest,
547 Eio_Progress_Cb progress_cb,
548 Eio_Done_Cb done_cb,
549 Eio_Error_Cb error_cb,
550 const void *data);
551
552/**
553 * @brief Move a directory and its content asynchronously
554 * @param source Should be the name of the directory to copy the data from.
555 * @param dest Should be the name of the directory to copy the data to.
556 * @param filter_cb Possible to deny the move of some files/directories.
557 * @param progress_cb Callback called to know the progress of the copy.
558 * @param done_cb Callback called when the copy is done.
559 * @param error_cb Callback called when something goes wrong.
560 * @param data Unmodified user data passed to callbacks
561 * @return A reference to the I/O operation.
562 *
563 * @return an Eio_File pointer, handler to the move operation, can be used to cancel the operation
564 *
565 * This function will move a directory and all its content from source to dest.
566 * It will try first to rename the directory, if not it will try to use splice
567 * if possible, if not it will fallback to mmap/write.
568 * It will try to preserve access rights, but not user/group identity.
569 * Every file will be passed to the filter_cb, so it's your job to decide if you
570 * want to pass the file to the main_cb or not. Return EINA_TRUE to pass it to
571 * the main_cb or EINA_FALSE to ignore it.
572 *
573 * @note if a rename occurs, the filter callback will not be called.
574 */
575EAPI Eio_File *eio_dir_move(const char *source,
576 const char *dest,
577 Eio_Filter_Direct_Cb filter_cb,
578 Eio_Progress_Cb progress_cb,
579 Eio_Done_Cb done_cb,
580 Eio_Error_Cb error_cb,
581 const void *data);
582
583/**
584 * @brief Copy a directory and its content asynchronously
585 * @param source Should be the name of the directory to copy the data from.
586 * @param dest Should be the name of the directory to copy the data to.
587 * @param filter_cb Possible to deny the move of some files/directories.
588 * @param progress_cb Callback called to know the progress of the copy.
589 * @param done_cb Callback called when the copy is done.
590 * @param error_cb Callback called when something goes wrong.
591 * @param data Unmodified user data passed to callbacks
592 * @return A reference to the I/O operation.
593 *
594 * @return an Eio_File pointer, handler to the copy operation, can be used to cancel the operation
595 *
596 * This function will copy a directory and all its content from source to dest.
597 * It will try to use splice if possible, if not it will fallback to mmap/write.
598 * It will try to preserve access rights, but not user/group identity.
599 * Every file will be passed to the filter_cb, so it's your job to decide if you
600 * want to pass the file to the main_cb or not. Return EINA_TRUE to pass it to
601 * the main_cb or EINA_FALSE to ignore it.
602 */
603EAPI Eio_File *eio_dir_copy(const char *source,
604 const char *dest,
605 Eio_Filter_Direct_Cb filter_cb,
606 Eio_Progress_Cb progress_cb,
607 Eio_Done_Cb done_cb,
608 Eio_Error_Cb error_cb,
609 const void *data);
610
611/**
612 * @brief Remove a directory and its content asynchronously
613 * @param path Should be the name of the directory to destroy.
614 * @param filter_cb Possible to deny the move of some files/directories.
615 * @param progress_cb Callback called to know the progress of the copy.
616 * @param done_cb Callback called when the copy is done.
617 * @param error_cb Callback called when something goes wrong.
618 * @param data Unmodified user data passed to callbacks
619 * @return A reference to the I/O operation.
620 *
621 * @return an Eio_File pointer, handler to the unlink operation, can be used to cancel the operation
622 *
623 * This function will remove a directory and all its content.
624 * Every file will be passed to the filter_cb, so it's your job to decide if you
625 * want to pass the file to the main_cb or not. Return EINA_TRUE to pass it to
626 * the main_cb or EINA_FALSE to ignore it.
627 */
628EAPI Eio_File *eio_dir_unlink(const char *path,
629 Eio_Filter_Direct_Cb filter_cb,
630 Eio_Progress_Cb progress_cb,
631 Eio_Done_Cb done_cb,
632 Eio_Error_Cb error_cb,
633 const void *data);
634/**
635 * @}
636 */
637
638/**
639 * @defgroup Eio_Xattr Eio manipulation of eXtended attribute.
640 * @ingroup Eio
641 *
642 * @brief A set of function to manipulate data associated with a specific file
643 *
644 * The functions provided by this API are responsible to manage Extended
645 * attribute files. Like file authors, character encoding, checksum, etc.
646 * @{
647 */
648
649/**
650 * @brief Asynchronously list all eXtended attribute
651 * @param path The path to get the eXtended attribute from.
652 * @param filter_cb Callback called in the thread to validate the eXtended attribute.
653 * @param main_cb Callback called in the main loop for each accepted eXtended attribute.
654 * @param done_cb Callback called in the main loop when the all the eXtended attribute have been listed.
655 * @param error_cb Callback called in the main loop when something goes wrong during the listing of the eXtended attribute.
656 * @param data Unmodified user data passed to callbacks
657 * @return A reference to the I/O operation.
658 */
659EAPI Eio_File *eio_file_xattr(const char *path,
660 Eio_Filter_Cb filter_cb,
661 Eio_Main_Cb main_cb,
662 Eio_Done_Cb done_cb,
663 Eio_Error_Cb error_cb,
664 const void *data);
665
666/**
667 * @brief Define an extented attribute on a file/directory.
668 * @param path The path to set the attribute on.
669 * @param attribute The name of the attribute to define.
670 * @param xattr_int The value to link the attribute with.
671 * @param flags Whether to insert, replace or create the attribute.
672 * @param done_cb The callback called from the main loop when setxattr succeeded.
673 * @param error_cb The callback called from the main loop when setxattr failed.
674 * @param data Unmodified user data passed to callbacks
675 * @return A reference to the I/O operation.
676 *
677 * eio_file_xattr_int_set calls eina_xattr_int_set from another thread. This prevents blocking in your apps. If
678 * the writing succeeded, the done_cb will be called even if a cancel was requested, but came too late.
679 */
680EAPI Eio_File *eio_file_xattr_int_set(const char *path,
681 const char *attribute,
682 int xattr_int,
683 Eina_Xattr_Flags flags,
684 Eio_Done_Cb done_cb,
685 Eio_Error_Cb error_cb,
686 const void *data);
687
688/**
689 * @brief Define an extented attribute on a file/directory.
690 * @param path The path to set the attribute on.
691 * @param attribute The name of the attribute to define.
692 * @param xattr_double The value to link the attribute with.
693 * @param flags Whether to insert, replace or create the attribute.
694 * @param done_cb The callback called from the main loop when setxattr succeeded.
695 * @param error_cb The callback called from the main loop when setxattr failed.
696 * @param data Unmodified user data passed to callbacks
697 * @return A reference to the I/O operation.
698 *
699 * eio_file_xattr_double_set calls eina_xattr_double_set from another thread. This prevents blocking in your apps. If
700 * the writing succeeded, the done_cb will be called even if a cancel was requested, but came too late.
701 */
702EAPI Eio_File *eio_file_xattr_double_set(const char *path,
703 const char *attribute,
704 double xattr_double,
705 Eina_Xattr_Flags flags,
706 Eio_Done_Cb done_cb,
707 Eio_Error_Cb error_cb,
708 const void *data);
709/**
710 * @brief Define a string extented attribute on a file/directory.
711 * @param path The path to set the attribute on.
712 * @param attribute The name of the attribute to define.
713 * @param xattr_string The string to link the attribute with.
714 * @param flags Whether to insert, replace or create the attribute.
715 * @param done_cb The callback called from the main loop when setxattr succeeded.
716 * @param error_cb The callback called from the main loop when setxattr failed.
717 * @param data Unmodified user data passed to callbacks
718 * @return A reference to the I/O operation.
719 *
720 * eio_file_xattr_string_set calls eina_xattr_string_set from another thread. This prevents blocking in your apps. If
721 * the writing succeeded, the done_cb will be called even if a cancel was requested, but came too late.
722 */
723EAPI Eio_File *eio_file_xattr_string_set(const char *path,
724 const char *attribute,
725 const char *xattr_string,
726 Eina_Xattr_Flags flags,
727 Eio_Done_Cb done_cb,
728 Eio_Error_Cb error_cb,
729 const void *data);
730/**
731 * @brief Define an extented attribute on a file/directory.
732 * @param path The path to set the attribute on.
733 * @param attribute The name of the attribute to define.
734 * @param xattr_data The data to link the attribute with.
735 * @param xattr_size The size of the data to set.
736 * @param flags Whether to insert, replace or create the attribute.
737 * @param done_cb The callback called from the main loop when setxattr succeeded.
738 * @param error_cb The callback called from the main loop when setxattr failed.
739 * @param data Unmodified user data passed to callbacks
740 * @return A reference to the I/O operation.
741 *
742 * eio_file_xattr_set calls setxattr from another thread. This prevents blocking in your apps. If
743 * the writing succeeded, the done_cb will be called even if a cancel was requested, but came too late.
744 */
745EAPI Eio_File *eio_file_xattr_set(const char *path,
746 const char *attribute,
747 const char *xattr_data,
748 unsigned int xattr_size,
749 Eina_Xattr_Flags flags,
750 Eio_Done_Cb done_cb,
751 Eio_Error_Cb error_cb,
752 const void *data);
753
754/**
755 * @brief Retrieve the extended attribute of a file/directory.
756 * @param path The path to retrieve the extended attribute from.
757 * @param attribute The name of the attribute to retrieve.
758 * @param done_cb Callback called from the main loop when getxattr succeeded.
759 * @param error_cb Callback called from the main loop when getxattr failed or has been canceled.
760 * @param data Unmodified user data passed to callbacks
761 * @return A reference to the I/O operation.
762 *
763 * eio_file_xattr_get calls getxattr from another thread. This prevents blocking in your apps.
764 */
765EAPI Eio_File *eio_file_xattr_get(const char *path,
766 const char *attribute,
767 Eio_Done_Data_Cb done_cb,
768 Eio_Error_Cb error_cb,
769 const void *data);
770/**
771 * @brief Retrieve a extended attribute of a file/directory.
772 * @param path The path to retrieve the extended attribute from.
773 * @param attribute The name of the attribute to retrieve.
774 * @param done_cb Callback called from the main loop when getxattr succeeded.
775 * @param error_cb Callback called from the main loop when getxattr failed or has been canceled.
776 * @param data Unmodified user data passed to callbacks
777 * @return A reference to the I/O operation.
778 *
779 * eio_file_xattr_int_get calls eina_xattr_int_get from another thread. This prevents blocking in your apps.
780 */
781EAPI Eio_File *eio_file_xattr_int_get(const char *path,
782 const char *attribute,
783 Eio_Done_Int_Cb done_cb,
784 Eio_Error_Cb error_cb,
785 const void *data);
786/**
787 * @brief Retrieve a extended attribute of a file/directory.
788 * @param path The path to retrieve the extended attribute from.
789 * @param attribute The name of the attribute to retrieve.
790 * @param done_cb Callback called from the main loop when getxattr succeeded.
791 * @param error_cb Callback called from the main loop when getxattr failed or has been canceled.
792 * @param data Unmodified user data passed to callbacks
793 * @return A reference to the I/O operation.
794 *
795 * eio_file_xattr_double_get calls eina_xattr_double_get from another thread. This prevents blocking in your apps.
796 */
797EAPI Eio_File *eio_file_xattr_double_get(const char *path,
798 const char *attribute,
799 Eio_Done_Double_Cb done_cb,
800 Eio_Error_Cb error_cb,
801 const void *data);
802/**
803 * @brief Retrieve a string extended attribute of a file/directory.
804 * @param path The path to retrieve the extended attribute from.
805 * @param attribute The name of the attribute to retrieve.
806 * @param done_cb Callback called from the main loop when getxattr succeeded.
807 * @param error_cb Callback called from the main loop when getxattr failed or has been canceled.
808 * @param data Unmodified user data passed to callbacks
809 * @return A reference to the I/O operation.
810 *
811 * eio_file_xattr_string_get calls eina_xattr_string_get from another thread. This prevents blocking in your apps.
812 */
813EAPI Eio_File *eio_file_xattr_string_get(const char *path,
814 const char *attribute,
815 Eio_Done_String_Cb done_cb,
816 Eio_Error_Cb error_cb,
817 const void *data);
818
819/**
820 * @}
821 */
822
823/**
824 * @defgroup Eio_Helper Eio Reference helper API
825 * @ingroup Eio
826 *
827 * @brief This are helper provided around core Eio API.
828 *
829 * This set of functions do provide helper to work around data
830 * provided by Eio without the need to look at system header.
831 *
832 * @{
833 */
834
835
836/**
837 * @brief Initialize eio and all its required submodule.
838 * @return the current number of eio users.
839 */
840EAPI int eio_init(void);
841
842/**
843 * @brief Shutdown eio and all its submodule if possible.
844 * @return the number of pending users of eio.
845 */
846EAPI int eio_shutdown(void);
847
848/**
849 * @brief Set the limit to the maximum amount of memory used
850 * @param limit The actual limit to set.
851 *
852 * Eio work by burst, allocating memory in a thread and moving it
853 * back to the main loop. This result in quite some huge memory
854 * usage if the main loop is to slow to cope with the speed of the
855 * thread. By setting this limit, the thread will block until
856 * enough memory has been freed to be below the limit again.
857 *
858 * By default no limit is set and any value < 0 will mean no limit.
859 *
860 * @note You should give at least a reasonable amount of memory or
861 * the thread might stall.
862 * @since 1.10
863 */
864EAPI void eio_memory_burst_limit_set(size_t limit);
865
866/**
867 * @brief Get the actual limit to the maximum amount of memory used
868 * @return The current limit being set.
869 *
870 * @since 1.10
871 * @see eio_memory_burst_limit_set
872 */
873EAPI size_t eio_memory_burst_limit_get(void);
874
875/**
876 * @brief Return the container during EIO operation
877 * @param ls The asynchronous I/O operation to retrieve container from.
878 * @return NULL if not available, a DIRP if it is.
879 *
880 * This is only available and make sense in the thread callback, not in
881 * the mainloop.
882 */
883EAPI void *eio_file_container_get(Eio_File *ls);
884
885/**
886 * @brief Cancel any Eio_File.
887 * @param ls The asynchronous I/O operation to cancel.
888 * @return EINA_FALSE if the destruction is delayed, EINA_TRUE if it's done.
889 *
890 * This will cancel any kind of I/O operation and cleanup the mess. This means
891 * that it could take time to cancel an I/O.
892 */
893EAPI Eina_Bool eio_file_cancel(Eio_File *ls);
894
895/**
896 * @brief Check if an Eio_File operation has been cancelled.
897 * @param ls The asynchronous I/O operation to check.
898 * @return EINA_TRUE if it was canceled, EINA_FALSE other wise.
899 *
900 * In case of an error it also return EINA_TRUE.
901 */
902EAPI Eina_Bool eio_file_check(Eio_File *ls);
903
904/**
905 * @brief Associate data with the current filtered file.
906 * @param ls The Eio_File ls request currently calling the filter callback.
907 * @param key The key to associate data to.
908 * @param data The data to associate the data to.
909 * @param free_cb Optionally a function to call to free the associated data,
910 * @p data is passed as the callback data parameter. If no @p free_cb is provided
911 * the user @p data remains untouched.
912 * @return EINA_TRUE if insertion was fine.
913 *
914 * This function can only be safely called from within the filter callback.
915 * If you don't need to copy the key around you can use @ref eio_file_associate_direct_add
916 */
917EAPI Eina_Bool eio_file_associate_add(Eio_File *ls,
918 const char *key,
919 const void *data, Eina_Free_Cb free_cb);
920
921/**
922 * @brief Associate data with the current filtered file.
923 * @param ls The Eio_File ls request currently calling the filter callback.
924 * @param key The key to associate data to (will not be copied, and the pointer will not be used as long as the file is not notified).
925 * @param data The data to associate the data to.
926 * @param free_cb The function to call to free the associated data, @p free_cb will be called if not specified.
927 * @return EINA_TRUE if insertion was fine.
928 *
929 * This function can only be safely called from within the filter callback.
930 * If you need eio to make a proper copy of the @p key to be safe use
931 * @ref eio_file_associate_add instead.
932 */
933EAPI Eina_Bool eio_file_associate_direct_add(Eio_File *ls,
934 const char *key,
935 const void *data, Eina_Free_Cb free_cb);
936
937/**
938 * @brief Get the data associated during the filter callback inside the main loop
939 * @param ls The Eio_File ls request currently calling the notify callback.
940 * @param key The key pointing to the data to retrieve.
941 * @return the data associated with the key or @p NULL if not found.
942 */
943EAPI void *eio_file_associate_find(Eio_File *ls, const char *key);
944 72
945/** 73/**
946 * @brief get access time from a Eina_Stat 74 * @brief get access time from a Eina_Stat
@@ -982,381 +110,11 @@ static inline Eina_Bool eio_file_is_dir(const Eina_Stat *stat);
982 */ 110 */
983static inline Eina_Bool eio_file_is_lnk(const Eina_Stat *stat); 111static inline Eina_Bool eio_file_is_lnk(const Eina_Stat *stat);
984 112
985/**
986 * @}
987 */
988
989/**
990 *
991 */
992
993/**
994 * @defgroup Eio_Map Manipulate an Eina_File asynchronously
995 * @ingroup Eio
996 *
997 * @brief This function helps when manipulating a file asynchronously.
998 *
999 * These set of functions work on top of Eina_File and Ecore_Thread to
1000 * do basic operations on a file, like opening, closing and mapping a file to
1001 * memory.
1002 * @{
1003 */
1004
1005/**
1006 * @brief Asynchronously open a file.
1007 * @param name The file to open.
1008 * @param shared If it's a shared memory file.
1009 * @param open_cb Callback called in the main loop when the file has been successfully opened.
1010 * @param error_cb Callback called in the main loop when the file couldn't be opened.
1011 * @param data Unmodified user data passed to callbacks
1012 * @return Pointer to the file if successful or NULL otherwise.
1013 *
1014 */
1015EAPI Eio_File *eio_file_open(const char *name, Eina_Bool shared,
1016 Eio_Open_Cb open_cb,
1017 Eio_Error_Cb error_cb,
1018 const void *data);
1019
1020/**
1021 * @brief Asynchronously close a file.
1022 * @param f The file to close.
1023 * @param done_cb Callback called in the main loop when the file has been successfully closed.
1024 * @param error_cb Callback called in the main loop when the file couldn't be closed.
1025 * @param data Unmodified user data passed to callbacks
1026 * @return Pointer to the file if successful or NULL otherwise.
1027 */
1028EAPI Eio_File *eio_file_close(Eina_File *f,
1029 Eio_Done_Cb done_cb,
1030 Eio_Error_Cb error_cb,
1031 const void *data);
1032
1033/**
1034 * @brief Asynchronously map a file in memory.
1035 * @param f The file to map.
1036 * @param rule The rule to apply to the map.
1037 * @param filter_cb Callback called in the thread to validate the content of the map.
1038 * @param map_cb Callback called in the main loop when the file has been successfully mapped.
1039 * @param error_cb Callback called in the main loop when the file can't be mapped.
1040 * @param data Unmodified user data passed to callbacks
1041 * @return Pointer to the file if successful or NULL otherwise.
1042 *
1043 * The container of the Eio_File is the Eina_File.
1044 */
1045EAPI Eio_File *eio_file_map_all(Eina_File *f,
1046 Eina_File_Populate rule,
1047 Eio_Filter_Map_Cb filter_cb,
1048 Eio_Map_Cb map_cb,
1049 Eio_Error_Cb error_cb,
1050 const void *data);
1051
1052/**
1053 * @brief Asynchronously map a part of a file in memory.
1054 * @param f The file to map.
1055 * @param rule The rule to apply to the map.
1056 * @param offset The offset inside the file
1057 * @param length The length of the memory to map
1058 * @param filter_cb Callback called in the thread to validate the content of the map.
1059 * @param map_cb Callback called in the main loop when the file has been successfully mapped.
1060 * @param error_cb Callback called in the main loop when the file can't be mapped.
1061 * @param data Unmodified user data passed to callbacks
1062 * @return Pointer to the file if successful or NULL otherwise.
1063 *
1064 * The container of the Eio_File is the Eina_File.
1065 */
1066EAPI Eio_File *eio_file_map_new(Eina_File *f,
1067 Eina_File_Populate rule,
1068 unsigned long int offset,
1069 unsigned long int length,
1070 Eio_Filter_Map_Cb filter_cb,
1071 Eio_Map_Cb map_cb,
1072 Eio_Error_Cb error_cb,
1073 const void *data);
1074
1075/**
1076 * @}
1077 */
1078
1079/**
1080 * @defgroup Eio_Eet Eio asynchronous API for Eet file.
1081 * @ingroup Eio
1082 *
1083 * @brief This set of functions help in the asynchronous use of Eet
1084 *
1085 * @{
1086 */
1087
1088/**
1089 * @brief Open an eet file on disk, and returns a handle to it asynchronously.
1090 * @param filename The file path to the eet file. eg: @c "/tmp/file.eet".
1091 * @param mode The mode for opening. Either EET_FILE_MODE_READ,
1092 * EET_FILE_MODE_WRITE or EET_FILE_MODE_READ_WRITE.
1093 * @param eet_cb The callback to call when the file has been successfully opened.
1094 * @param error_cb Callback called in the main loop when the file can't be opened.
1095 * @param data Unmodified user data passed to callbacks
1096 * @return NULL in case of a failure.
1097 *
1098 * This function calls eet_open() from another thread using Ecore_Thread.
1099 */
1100EAPI Eio_File *eio_eet_open(const char *filename,
1101 Eet_File_Mode mode,
1102 Eio_Eet_Open_Cb eet_cb,
1103 Eio_Error_Cb error_cb,
1104 const void *data);
1105/**
1106 * @brief Close an eet file handle and flush pending writes asynchronously.
1107 * @param ef A valid eet file handle.
1108 * @param done_cb Callback called from the main loop when the file has been closed.
1109 * @param error_cb Callback called in the main loop when the file can't be closed.
1110 * @param data Unmodified user data passed to callbacks
1111 * @return NULL in case of a failure.
1112 *
1113 * This function will call eet_close() from another thread by
1114 * using Ecore_Thread. You should assume that the Eet_File is dead after this
1115 * function is called.
1116 */
1117EAPI Eio_File *eio_eet_close(Eet_File *ef,
1118 Eio_Done_Cb done_cb,
1119 Eio_Eet_Error_Cb error_cb,
1120 const void *data);
1121
1122/**
1123 * @brief Sync content of an eet file handle, flushing pending writes asynchronously.
1124 * @param ef A valid eet file handle.
1125 * @param done_cb Callback called from the main loop when the file has been synced.
1126 * @param error_cb Callback called in the main loop when the file can't be synced.
1127 * @param data Unmodified user data passed to callbacks
1128 * @return NULL in case of a failure.
1129 *
1130 * This function will call eet_sync() from another thread. As long as the done_cb or
1131 * error_cb haven't be called, you must keep @p ef open.
1132 */
1133EAPI Eio_File *eio_eet_sync(Eet_File *ef,
1134 Eio_Done_Cb done_cb,
1135 Eio_Eet_Error_Cb error_cb,
1136 const void *data);
1137
1138/**
1139 * @brief Write a data structure from memory and store in an eet file
1140 * using a cipher asynchronously.
1141 * @param ef The eet file handle to write to.
1142 * @param edd The data descriptor to use when encoding.
1143 * @param name The key to store the data under in the eet file.
1144 * @param cipher_key The key to use as cipher.
1145 * @param write_data A pointer to the data structure to save and encode.
1146 * @param compress Compression flags for storage.
1147 * @param done_cb Callback called from the main loop when the data has been put in the Eet_File.
1148 * @param error_cb Callback called in the main loop when the file can't be written.
1149 * @param user_data Private data given to each callback.
1150 * @return NULL in case of a failure.
1151 */
1152EAPI Eio_File *eio_eet_data_write_cipher(Eet_File *ef,
1153 Eet_Data_Descriptor *edd,
1154 const char *name,
1155 const char *cipher_key,
1156 void *write_data,
1157 int compress,
1158 Eio_Done_Int_Cb done_cb,
1159 Eio_Error_Cb error_cb,
1160 const void *user_data);
1161
1162/**
1163 * @brief Read a data structure from an eet file and decodes it using a cipher asynchronously.
1164 * @param ef The eet file handle to read from.
1165 * @param edd The data descriptor handle to use when decoding.
1166 * @param name The key the data is stored under in the eet file.
1167 * @param cipher_key The key to use as cipher.
1168 * @param done_cb Callback called from the main loop when the data has been read and decoded.
1169 * @param error_cb Callback called in the main loop when the data can't be read.
1170 * @param data Unmodified user data passed to callbacks
1171 * @return NULL in case of a failure.
1172 */
1173EAPI Eio_File *eio_eet_data_read_cipher(Eet_File *ef,
1174 Eet_Data_Descriptor *edd,
1175 const char *name,
1176 const char *cipher_key,
1177 Eio_Done_ERead_Cb done_cb,
1178 Eio_Error_Cb error_cb,
1179 const void *data);
1180
1181/**
1182 * @brief Write image data to the named key in an eet file asynchronously.
1183 * @param ef A valid eet file handle opened for writing.
1184 * @param name Name of the entry. eg: "/base/file_i_want".
1185 * @param cipher_key The key to use as cipher.
1186 * @param write_data A pointer to the image pixel data.
1187 * @param w The width of the image in pixels.
1188 * @param h The height of the image in pixels.
1189 * @param alpha The alpha channel flag.
1190 * @param compress The compression amount.
1191 * @param quality The quality encoding amount.
1192 * @param lossy The lossiness flag.
1193 * @param done_cb Callback called from the main loop when the data has been put in the Eet_File.
1194 * @param error_cb Callback called in the main loop when the file can't be written.
1195 * @param user_data Private data given to each callback.
1196 * @return NULL in case of a failure.
1197 */
1198EAPI Eio_File *eio_eet_data_image_write_cipher(Eet_File *ef,
1199 const char *name,
1200 const char *cipher_key,
1201 void *write_data,
1202 unsigned int w,
1203 unsigned int h,
1204 int alpha,
1205 int compress,
1206 int quality,
1207 int lossy,
1208 Eio_Done_Int_Cb done_cb,
1209 Eio_Error_Cb error_cb,
1210 const void *user_data);
1211
1212/**
1213 * @brief Read a specified entry from an eet file and return data
1214 * @param ef A valid eet file handle opened for reading.
1215 * @param name Name of the entry. eg: "/base/file_i_want".
1216 * @param done_cb Callback called from the main loop when the data has been read.
1217 * @param error_cb Callback called in the main loop when the data can't be read.
1218 * @param data Unmodified user data passed to callbacks
1219 * @return NULL in case of a failure.
1220 */
1221EAPI Eio_File *eio_eet_read_direct(Eet_File *ef,
1222 const char *name,
1223 Eio_Done_Data_Cb done_cb,
1224 Eio_Error_Cb error_cb,
1225 const void *data);
1226
1227/**
1228 * @brief Read a specified entry from an eet file and return data
1229 * @param ef A valid eet file handle opened for reading.
1230 * @param name Name of the entry. eg: "/base/file_i_want".
1231 * @param cipher_key The key to use as cipher.
1232 * @param done_cb Callback called from the main loop when the data has been read.
1233 * @param error_cb Callback called in the main loop when the data can't be read.
1234 * @param data Unmodified user data passed to callbacks
1235 * @return NULL in case of a failure.
1236 */
1237EAPI Eio_File *eio_eet_read_cipher(Eet_File *ef,
1238 const char *name,
1239 const char *cipher_key,
1240 Eio_Done_Read_Cb done_cb,
1241 Eio_Error_Cb error_cb,
1242 const void *data);
1243
1244/**
1245 * @brief Write a specified entry to an eet file handle using a cipher.
1246 * @param ef A valid eet file handle opened for writing.
1247 * @param name Name of the entry. eg: "/base/file_i_want".
1248 * @param write_data Pointer to the data to be stored.
1249 * @param size Length in bytes in the data to be stored.
1250 * @param compress Compression flags (1 == compress, 0 = don't compress).
1251 * @param cipher_key The key to use as cipher.
1252 * @param done_cb Callback called from the main loop when the data has been put in the Eet_File.
1253 * @param error_cb Callback called in the main loop when the file can't be written.
1254 * @param user_data Private data given to each callback.
1255 * @return NULL in case of a failure.
1256 */
1257EAPI Eio_File *eio_eet_write_cipher(Eet_File *ef,
1258 const char *name,
1259 void *write_data,
1260 int size,
1261 int compress,
1262 const char *cipher_key,
1263 Eio_Done_Int_Cb done_cb,
1264 Eio_Error_Cb error_cb,
1265 const void *user_data);
1266
1267/**
1268 * @}
1269 */
1270
1271/**
1272 * @defgroup Eio_Monitor Eio file and directory monitoring API
1273 * @ingroup Eio
1274 *
1275 * @brief These function monitor changes in directories and files
1276 *
1277 * These functions use the best available method to monitor changes on a specified directory
1278 * or file. They send ecore events when changes occur, and they maintain internal refcounts to
1279 * reduce resource consumption on duplicate monitor targets.
1280 *
1281 * @{
1282 */
1283
1284EAPI extern int EIO_MONITOR_FILE_CREATED; /**< A new file was created in a watched directory */
1285EAPI extern int EIO_MONITOR_FILE_DELETED; /**< A watched file was deleted, or a file in a watched directory was deleted */
1286EAPI extern int EIO_MONITOR_FILE_MODIFIED; /**< A file was modified in a watched directory */
1287EAPI extern int EIO_MONITOR_FILE_CLOSED; /**< A file was closed in a watched directory. This event is never sent on Windows and OSX */
1288EAPI extern int EIO_MONITOR_DIRECTORY_CREATED; /**< A new directory was created in a watched directory */
1289EAPI extern int EIO_MONITOR_DIRECTORY_DELETED; /**< A directory has been deleted: this can be either a watched directory or one of its subdirectories */
1290EAPI extern int EIO_MONITOR_DIRECTORY_MODIFIED; /**< A directory has been modified in a watched directory */
1291EAPI extern int EIO_MONITOR_DIRECTORY_CLOSED; /**< A directory has been closed in a watched directory. This event is never sent on Windows and OSX */
1292EAPI extern int EIO_MONITOR_SELF_RENAME; /**< The monitored path has been renamed, an error could happen just after if the renamed path doesn't exist. This event is never sent on OSX */
1293EAPI extern int EIO_MONITOR_SELF_DELETED; /**< The monitored path has been removed. This event is never sent on OSX */
1294EAPI extern int EIO_MONITOR_ERROR; /**< During operation the monitor failed and will no longer work. eio_monitor_del must be called on it. */
1295
1296typedef struct _Eio_Monitor Eio_Monitor;
1297
1298typedef struct _Eio_Monitor_Error Eio_Monitor_Error;
1299typedef struct _Eio_Monitor_Event Eio_Monitor_Event;
1300
1301struct _Eio_Monitor_Error
1302{
1303 Eio_Monitor *monitor;
1304 int error;
1305};
1306
1307struct _Eio_Monitor_Event
1308{
1309 Eio_Monitor *monitor;
1310 const char *filename;
1311};
1312
1313/**
1314 * @brief Adds a file/directory to monitor (inotify mechanism)
1315 * @param path file/directory to monitor
1316 * @return NULL in case of a failure or a pointer to the monitor in case of
1317 * success.
1318 *
1319 * This function will add the given path to its internal
1320 * list of files to monitor. It utilizes the inotify mechanism
1321 * introduced in kernel 2.6.13 for passive monitoring.
1322 */
1323EAPI Eio_Monitor *eio_monitor_add(const char *path);
1324
1325/**
1326 * @brief Adds a file/directory to monitor
1327 * @param path file/directory to monitor
1328 * @return NULL in case of a failure or a pointer to the monitor in case of
1329 * success.
1330 * @warning Do NOT pass non-stringshared strings to this function!
1331 * If you don't know what this means, use eio_monitor_add().
1332 *
1333 * This fuction is just like eio_monitor_add(), however the string passed by
1334 * argument must be created using eina_stringshare_add().
1335 */
1336EAPI Eio_Monitor *eio_monitor_stringshared_add(const char *path);
1337
1338/**
1339 * @brief Deletes a path from the “watched” list
1340 * @param monitor The Eio_Monitor you want to stop watching.
1341 * It can only be an Eio_Monitor returned to you from calling
1342 * eio_monitor_add() or eio_monitor_stringshared_add()
1343 */
1344EAPI void eio_monitor_del(Eio_Monitor *monitor);
1345
1346/**
1347 * @brief returns the path being watched by the given
1348 * Eio_Monitor.
1349 * @param monitor Eio_Monitor to return the path of
1350 * @return The stringshared path belonging to @p monitor
1351 */
1352EAPI const char *eio_monitor_path_get(Eio_Monitor *monitor);
1353
1354/**
1355 * @}
1356 */
1357
1358#include "eio_inline_helper.x" 113#include "eio_inline_helper.x"
1359 114
115#define EIO_VERSION_MAJOR EFL_VERSION_MAJOR
116#define EIO_VERSION_MINOR EFL_VERSION_MINOR
117
1360#ifdef __cplusplus 118#ifdef __cplusplus
1361} 119}
1362#endif 120#endif
diff --git a/src/lib/eio/Eio_Eo.h b/src/lib/eio/Eio_Eo.h
new file mode 100644
index 0000000000..ebd2d502fd
--- /dev/null
+++ b/src/lib/eio/Eio_Eo.h
@@ -0,0 +1,13 @@
1/* This include has been added to support Eo in Eio */
2#include <Eo.h>
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include "eio_job.eo.h"
9#include "eio_sentry.eo.h"
10
11#ifdef __cplusplus
12}
13#endif
diff --git a/src/lib/eio/Eio_Legacy.h b/src/lib/eio/Eio_Legacy.h
new file mode 100644
index 0000000000..833a21499d
--- /dev/null
+++ b/src/lib/eio/Eio_Legacy.h
@@ -0,0 +1,1256 @@
1#ifdef __cplusplus
2extern "C" {
3#endif
4
5 /**
6 * @typedef Eio_Version
7 * Represents the current version of EIO
8 */
9 typedef struct _Eio_Version
10 {
11 int major; /**< Major version number */
12 int minor; /**< Minor version number */
13 int micro; /**< Micro version number */
14 int revision; /**< Revision number */
15 } Eio_Version;
16
17 EAPI extern Eio_Version *eio_version;
18
19/**
20 * @file
21 * @brief Eio asynchronous input/output library
22 *
23 * These routines are used for Eio.
24 */
25
26/**
27 * @page eio_main Eio
28 *
29 * @date 2012 (created)
30 *
31 * @section toc Table of Contents
32 *
33 * @li @ref eio_main_intro
34 * @li @ref eio_main_compiling
35 * @li @ref eio_main_next_steps
36 * @li @ref eio_main_intro_example
37 *
38 * @section eio_main_intro Introduction
39 *
40 * The Eio library is a library that implements an API for asynchronous
41 * input/output operation. Most operations are done in a separate thread
42 * to prevent lock. See @ref Eio_Group. Some helper to work on data
43 * received in Eio callback are also provided see @ref Eio_Helper.
44 * It is also possible to work asynchronously on Eina_File with @ref Eio_Map
45 * or on Eet_File with @ref Eio_Eet. It comes with way to manipulate
46 * eXtended attribute asynchronous with @ref Eio_Xattr.
47 *
48 * This library is cross-platform and can be compiled and used on
49 * Linux, BSD, Opensolaris and Windows (XP and CE). It is heavily
50 * based on @ref Ecore_Main_Loop_Group.
51 *
52 * @section eio_main_compiling How to compile
53 *
54 * Eio is a library your application links to. The procedure for this is
55 * very simple. You simply have to compile your application with the
56 * appropriate compiler flags that the @c pkg-config script outputs. For
57 * example:
58 *
59 * Compiling C or C++ files into object files:
60 *
61 * @verbatim
62 gcc -c -o main.o main.c `pkg-config --cflags eio`
63 @endverbatim
64 *
65 * Linking object files into a binary executable:
66 *
67 * @verbatim
68 gcc -o my_application main.o `pkg-config --libs eio`
69 @endverbatim
70 *
71 * See @ref pkgconfig
72 *
73 * @section eio_main_next_steps Next Steps
74 *
75 * After you understand what Eio is and installed it on your system
76 * you should proceed understand the programming interface.
77 *
78 * Recommended reading:
79 *
80 * @li @ref Eio_Helper for common functions and library initialization.
81 * @li @ref Eio_List for listing files asynchronous.
82 * @li @ref Eio_Management for anyone who want to do a file manager (copy, rm, ...).
83 * @li @ref Eio_Map to manipulate files asynchronously (mmap).
84 * @li @ref Eio_Xattr to access file extended attributes (xattr).
85 * @li @ref Eio_Monitor to monitor for file changes (inotify).
86 * @li @ref Eio_Eet to access Eet files asynchronously.
87 *
88 * @section eio_main_intro_example Introductory Example
89 *
90 * @include eio_file_ls.c
91 *
92 * More examples can be found at @ref eio_examples.
93 *
94 */
95
96/**
97 * @enum _Eio_File_Op
98 *
99 * @brief Input/Output operations on files.
100 *
101 * This enum represents the operations that can be done.
102 */
103enum _Eio_File_Op
104{
105 EIO_FILE_COPY, /**< I/O operation is about a specific file copy */
106 EIO_FILE_MOVE, /**< I/O operation is about a specific file move */
107 EIO_DIR_COPY, /**< I/O operation is about a specific directory copy */
108 EIO_DIR_MOVE, /**< I/O operation is about a specific directory move */
109 /** I/O operation is about destroying a path:
110 * source will point to base path to be destroyed,
111 * and dest will point to to path destroyed by this I/O
112 */
113 EIO_UNLINK,
114 EIO_FILE_GETPWNAM, /**< I/O operation is trying to get uid from user name */
115 EIO_FILE_GETGRNAM /**< I/O operation is trying to get gid from user name */
116};
117
118/**
119 * @typedef Eio_File_Op
120 * Input/Output operations on files.
121 */
122typedef enum _Eio_File_Op Eio_File_Op;
123
124/**
125 * @defgroup Eio_List Eio file listing API
126 * @ingroup Eio
127 *
128 * @brief This functions helps list files asynchronously.
129 *
130 * This set of functions work on top of Eina_File and Ecore_Thread
131 * to list files under various condition.
132 *
133 * @{
134 */
135
136/**
137 * @typedef Eio_File
138 * Generic asynchronous I/O reference.
139 */
140typedef struct _Eio_File Eio_File;
141
142/**
143 * @typedef Eio_Progress
144 * Progress information on a specific operation.
145 */
146typedef struct _Eio_Progress Eio_Progress;
147
148typedef Eina_Bool (*Eio_Filter_Cb)(void *data, Eio_File *handler, const char *file);
149typedef void (*Eio_Main_Cb)(void *data, Eio_File *handler, const char *file);
150
151typedef Eina_Bool (*Eio_Filter_Direct_Cb)(void *data, Eio_File *handler, const Eina_File_Direct_Info *info);
152typedef Eina_Bool (*Eio_Filter_Dir_Cb)(void *data, Eio_File *handler, Eina_File_Direct_Info *info);
153typedef void (*Eio_Main_Direct_Cb)(void *data, Eio_File *handler, const Eina_File_Direct_Info *info);
154
155typedef void (*Eio_Stat_Cb)(void *data, Eio_File *handler, const Eina_Stat *stat);
156typedef void (*Eio_Progress_Cb)(void *data, Eio_File *handler, const Eio_Progress *info);
157
158typedef void (*Eio_Eet_Open_Cb)(void *data, Eio_File *handler, Eet_File *file);
159typedef void (*Eio_Open_Cb)(void *data, Eio_File *handler, Eina_File *file);
160typedef Eina_Bool (*Eio_Filter_Map_Cb)(void *data, Eio_File *handler, void *map, size_t length);
161typedef void (*Eio_Map_Cb)(void *data, Eio_File *handler, void *map, size_t length);
162
163typedef void (*Eio_Done_Data_Cb)(void *data, Eio_File *handler, const char *read_data, unsigned int size);
164typedef void (*Eio_Done_String_Cb)(void *data, Eio_File *handler, const char *xattr_string);
165typedef void (*Eio_Done_Double_Cb)(void *data, Eio_File *handler, double xattr_double);
166typedef void (*Eio_Done_Int_Cb)(void *data, Eio_File *handler, int i);
167
168typedef void (*Eio_Done_ERead_Cb)(void *data, Eio_File *handler, void *decoded);
169typedef void (*Eio_Done_Read_Cb)(void *data, Eio_File *handler, void *read_data, unsigned int size);
170typedef void (*Eio_Done_Cb)(void *data, Eio_File *handler);
171typedef void (*Eio_Error_Cb)(void *data, Eio_File *handler, int error);
172typedef void (*Eio_Eet_Error_Cb)(void *data, Eio_File *handler, Eet_Error err);
173
174/**
175 * @struct _Eio_Progress
176 * @brief Represents the current progress of the operation.
177 */
178struct _Eio_Progress
179{
180 Eio_File_Op op; /**< I/O type */
181
182 long long current; /**< Current step in the I/O operation */
183 long long max; /**< Number of total steps to complete this I/O */
184 float percent; /**< Percent done for the I/O operation */
185
186 const char *source; /**< source of the I/O operation */
187 const char *dest; /**< target of the I/O operation */
188};
189
190/**
191 * @brief List contents of a directory without locking your app.
192 * @param dir The directory to list.
193 * @param filter_cb Callback used to decide if the file will be passed to main_cb
194 * @param main_cb Callback called for each listed file if it was not filtered.
195 * @param done_cb Callback called when the ls operation is done.
196 * @param error_cb Callback called when either the directory could not be opened or the operation has been canceled.
197 * @param data Unmodified user data passed to callbacks
198 * @return A reference to the I/O operation.
199 *
200 * This function is responsible for listing the content of a directory without blocking your application.
201 * It's equivalent to the "ls" shell command. Every file will be passed to the
202 * filter_cb, so it's your job to decide if you want to pass the file to the
203 * main_cb or not. Return EINA_TRUE to pass it to the main_cb or EINA_FALSE to
204 * ignore it. It runs eina_file_ls() in a separate thread using
205 * ecore_thread_feedback_run().
206 *
207 * @see eina_file_ls()
208 * @see ecore_thread_feedback_run()
209 * @see eio_file_direct_ls()
210 * @see eio_file_stat_ls()
211 */
212EAPI Eio_File *eio_file_ls(const char *dir,
213 Eio_Filter_Cb filter_cb,
214 Eio_Main_Cb main_cb,
215 Eio_Done_Cb done_cb,
216 Eio_Error_Cb error_cb,
217 const void *data);
218
219/**
220 * @brief List contents of a directory without locking your app.
221 * @param dir The directory to list.
222 * @param filter_cb Callback used to decide if the file will be passed to main_cb
223 * @param main_cb Callback called from the main loop for each accepted file (not filtered).
224 * @param done_cb Callback called from the main loop after the contents of the directory has been listed.
225 * @param error_cb Callback called from the main loop when either the directory could not be opened or the operation has been canceled.
226 * @param data Unmodified user data passed to callbacks
227 * @return A reference to the I/O operation.
228 *
229 * eio_file_direct_ls() runs eina_file_direct_ls() in a separate thread using
230 * ecore_thread_feedback_run(). This prevents any blocking in your apps.
231 * Every file will be passed to the filter_cb, so it's your job to decide if you
232 * want to pass the file to the main_cb or not. Return EINA_TRUE to pass it to
233 * the main_cb or EINA_FALSE to ignore it.
234 *
235 * @warning If readdir_r doesn't contain file type information, file type is
236 * EINA_FILE_UNKNOWN.
237 *
238 * @note The iterator walks over '.' and '..' without returning them.
239 * @note The difference between this function and eina_file_stat_ls() is that
240 * it may not get the file type information however it is likely to be
241 * faster.
242 *
243 * @see eio_file_stat_ls()
244 * @see eina_file_direct_ls()
245 * @see ecore_thread_feedback_run()
246 */
247EAPI Eio_File *eio_file_direct_ls(const char *dir,
248 Eio_Filter_Direct_Cb filter_cb,
249 Eio_Main_Direct_Cb main_cb,
250 Eio_Done_Cb done_cb,
251 Eio_Error_Cb error_cb,
252 const void *data);
253
254/**
255 * @brief List content of a directory without locking your app.
256 * @param dir The directory to list.
257 * @param filter_cb Callback used to decide if the file will be passed to main_cb
258 * @param main_cb Callback called from the main loop for each accepted file (not filtered).
259 * @param done_cb Callback called from the main loop after the contents of the directory has been listed.
260 * @param error_cb Callback called from the main loop when either the directory could not be opened or the operation has been canceled.
261 * @param data Unmodified user data passed to callbacks
262 * @return A reference to the I/O operation.
263 *
264 * Every file will be passed to the filter_cb, so it's your job to decide if you
265 * want to pass the file to the main_cb or not. Return EINA_TRUE to pass it to
266 * the main_cb or EINA_FALSE to ignore it. eio_file_stat_ls() run eina_file_stat_ls()
267 * in a separate thread using ecore_thread_feedback_run().
268 *
269 * @note The iterator walks over '.' and '..' without returning them.
270 * @note The difference between this function and eio_file_direct_ls() is that
271 * it guarantees the file type information to be correct by incurring a
272 * possible performance penalty.
273 *
274 * @see eio_file_stat_ls()
275 * @see eina_file_stat_ls()
276 * @see ecore_thread_feedback_run()
277 */
278EAPI Eio_File *eio_file_stat_ls(const char *dir,
279 Eio_Filter_Direct_Cb filter_cb,
280 Eio_Main_Direct_Cb main_cb,
281 Eio_Done_Cb done_cb,
282 Eio_Error_Cb error_cb,
283 const void *data);
284
285/**
286 * @brief List the content of a directory and all its sub-content asynchronously
287 * @param dir The directory to list.
288 * @param filter_cb Callback used to decide if the file will be passed to main_cb
289 * @param main_cb Callback called from the main loop for each accepted file (not filtered).
290 * @param done_cb Callback called from the main loop after the contents of the directory has been listed.
291 * @param error_cb Callback called from the main loop when either the directory could not be opened or the operation has been canceled.
292 * @param data Unmodified user data passed to callbacks
293 * @return A reference to the I/O operation.
294 *
295 * eio_dir_stat_ls() runs eina_file_stat_ls() recursively in a separate thread using
296 * ecore_thread_feedback_run(). This prevents any blocking in your apps.
297 * Every file will be passed to the
298 * filter_cb, so it's your job to decide if you want to pass the file to the
299 * main_cb or not. Return EINA_TRUE to pass it to the main_cb or EINA_FALSE to
300 * ignore it.
301 *
302 * @see eio_file_stat_ls()
303 * @see eio_dir_direct_ls()
304 * @see eina_file_stat_ls()
305 * @see ecore_thread_feedback_run()
306 */
307EAPI Eio_File *eio_dir_stat_ls(const char *dir,
308 Eio_Filter_Direct_Cb filter_cb,
309 Eio_Main_Direct_Cb main_cb,
310 Eio_Done_Cb done_cb,
311 Eio_Error_Cb error_cb,
312 const void *data);
313
314/**
315 * @brief List the content of a directory and all its sub-content asynchronously
316 * @param dir The directory to list.
317 * @param filter_cb Callback used to decide if the file will be passed to main_cb
318 * @param main_cb Callback called from the main loop for each accepted file (not filtered).
319 * @param done_cb Callback called from the main loop after the contents of the directory has been listed.
320 * @param error_cb Callback called from the main loop when either the directory could not be opened or the operation has been canceled.
321 * @param data Unmodified user data passed to callbacks
322 * @return A reference to the I/O operation.
323 *
324 * eio_dir_direct_ls() runs eina_file_direct_ls() recursively in a separate thread using
325 * ecore_thread_feedback_run(). This prevents any blocking in your apps.
326 * Every file will be passed to the filter_cb, so it's your job to decide if you
327 * want to pass the file to the main_cb or not. Return EINA_TRUE to pass it to
328 * the main_cb or EINA_FALSE to ignore it.
329 *
330 * @see eio_file_direct_ls()
331 * @see eio_dir_stat_ls()
332 * @see eina_file_direct_ls()
333 * @see ecore_thread_feedback_run()
334 */
335EAPI Eio_File *eio_dir_direct_ls(const char *dir,
336 Eio_Filter_Dir_Cb filter_cb,
337 Eio_Main_Direct_Cb main_cb,
338 Eio_Done_Cb done_cb,
339 Eio_Error_Cb error_cb,
340 const void *data);
341
342/**
343 * @brief Stat a file/directory.
344 * @param path The path to stat.
345 * @param done_cb Callback called from the main loop when stat was successfully called.
346 * @param error_cb Callback called from the main loop when stat failed or has been canceled.
347 * @param data Unmodified user data passed to callbacks
348 * @return A reference to the I/O operation.
349 *
350 * eio_file_direct_stat calls stat in another thread. This prevents any blocking in your apps.
351 */
352EAPI Eio_File *eio_file_direct_stat(const char *path,
353 Eio_Stat_Cb done_cb,
354 Eio_Error_Cb error_cb,
355 const void *data);
356
357/**
358 * @}
359 */
360
361/**
362 * @defgroup Eio_Management Eio file management API.
363 *
364 * @brief A set of function to manage file asynchronously.
365 *
366 * The function provided by this API are the one useful for any
367 * file manager. Like moving or copying a file, unlinking it, changing
368 * it's access right, ...
369 *
370 * @{
371 */
372
373/**
374 * @brief Change rights of a path.
375 * @param path The directory path to change access rights.
376 * @param mode The permission to set, follow (mode & ~umask & 0777).
377 * @param done_cb Callback called when the operation is completed.
378 * @param error_cb Callback called from if something goes wrong.
379 * @param data Unmodified user data passed to callbacks.
380 * @return A reference to the I/O operation.
381 *
382 * Set a new permission of a path changing it to the mode passed as argument.
383 * It's equivalent to the chmod command.
384 */
385EAPI Eio_File *eio_file_chmod(const char *path,
386 mode_t mode,
387 Eio_Done_Cb done_cb,
388 Eio_Error_Cb error_cb,
389 const void *data);
390
391/**
392 * @brief Change owner of a path.
393 * @param path The directory path to change owner.
394 * @param user The new user to set (can be NULL).
395 * @param group The new group to set (can be NULL).
396 * @param done_cb Callback called when the operation is completed.
397 * @param error_cb Callback called from if something goes wrong.
398 * @param data Unmodified user data passed to callbacks
399 * @return A reference to the I/O operation.
400 *
401 * This function will change the owner of a path, setting it to the user and
402 * group passed as argument. It's equivalent to the chown shell command.
403 */
404EAPI Eio_File *eio_file_chown(const char *path,
405 const char *user,
406 const char *group,
407 Eio_Done_Cb done_cb,
408 Eio_Error_Cb error_cb,
409 const void *data);
410
411/**
412 * @brief Unlink a file/directory.
413 * @param path The path to unlink.
414 * @param done_cb Callback called when the operation is completed.
415 * @param error_cb Callback called from if something goes wrong.
416 * @param data Unmodified user data passed to callbacks.
417 * @return A reference to the I/O operation.
418 *
419 * This function will erase a file.
420 */
421EAPI Eio_File *eio_file_unlink(const char *path,
422 Eio_Done_Cb done_cb,
423 Eio_Error_Cb error_cb,
424 const void *data);
425
426/**
427 * @brief Create a new directory.
428 * @param path The directory path to create.
429 * @param mode The permission to set, follow (mode & ~umask & 0777).
430 * @param done_cb Callback called when the operation is completed.
431 * @param error_cb Callback called from if something goes wrong.
432 * @param data Unmodified user data passed to callbacks
433 * @return A reference to the I/O operation.
434 *
435 * Creates a new directory using the mode provided.
436 */
437EAPI Eio_File *eio_file_mkdir(const char *path,
438 mode_t mode,
439 Eio_Done_Cb done_cb,
440 Eio_Error_Cb error_cb,
441 const void *data);
442
443/**
444 * @brief Move a file asynchronously
445 * @param source Should be the name of the file to move the data from.
446 * @param dest Should be the name of the file to move the data to.
447 * @param progress_cb Callback called to know the progress of the move.
448 * @param done_cb Callback called when the move is done.
449 * @param error_cb Callback called when something goes wrong.
450 * @param data Unmodified user data passed to callbacks
451 * @return A reference to the I/O operation.
452 *
453 * @return an Eio_File pointer, handler to the move operation, can be used to cancel the operation
454 *
455 * This function will copy a file from source to dest. It will try to use splice
456 * if possible, if not it will fallback to mmap/write. It will try to preserve
457 * access rights, but not user/group identification.
458 */
459EAPI Eio_File *eio_file_move(const char *source,
460 const char *dest,
461 Eio_Progress_Cb progress_cb,
462 Eio_Done_Cb done_cb,
463 Eio_Error_Cb error_cb,
464 const void *data);
465
466/**
467 * @brief Copy a file asynchronously
468 * @param source Should be the name of the file to copy the data from.
469 * @param dest Should be the name of the file to copy the data to.
470 * @param progress_cb Callback called to know the progress of the copy.
471 * @param done_cb Callback called when the copy is done.
472 * @param error_cb Callback called when something goes wrong.
473 * @param data Unmodified user data passed to callbacks
474 *
475 * @return an Eio_File pointer, handler to the copy operation, can be used to cancel the operation
476 *
477 * This function will copy a file from source to dest. It will try to use splice
478 * if possible, if not it will fallback to mmap/write. It will try to preserve
479 * access rights, but not user/group identification.
480 */
481EAPI Eio_File *eio_file_copy(const char *source,
482 const char *dest,
483 Eio_Progress_Cb progress_cb,
484 Eio_Done_Cb done_cb,
485 Eio_Error_Cb error_cb,
486 const void *data);
487
488/**
489 * @brief Move a directory and its content asynchronously
490 * @param source Should be the name of the directory to copy the data from.
491 * @param dest Should be the name of the directory to copy the data to.
492 * @param filter_cb Possible to deny the move of some files/directories.
493 * @param progress_cb Callback called to know the progress of the copy.
494 * @param done_cb Callback called when the copy is done.
495 * @param error_cb Callback called when something goes wrong.
496 * @param data Unmodified user data passed to callbacks
497 * @return A reference to the I/O operation.
498 *
499 * @return an Eio_File pointer, handler to the move operation, can be used to cancel the operation
500 *
501 * This function will move a directory and all its content from source to dest.
502 * It will try first to rename the directory, if not it will try to use splice
503 * if possible, if not it will fallback to mmap/write.
504 * It will try to preserve access rights, but not user/group identity.
505 * Every file will be passed to the filter_cb, so it's your job to decide if you
506 * want to pass the file to the main_cb or not. Return EINA_TRUE to pass it to
507 * the main_cb or EINA_FALSE to ignore it.
508 *
509 * @note if a rename occurs, the filter callback will not be called.
510 */
511EAPI Eio_File *eio_dir_move(const char *source,
512 const char *dest,
513 Eio_Filter_Direct_Cb filter_cb,
514 Eio_Progress_Cb progress_cb,
515 Eio_Done_Cb done_cb,
516 Eio_Error_Cb error_cb,
517 const void *data);
518
519/**
520 * @brief Copy a directory and its content asynchronously
521 * @param source Should be the name of the directory to copy the data from.
522 * @param dest Should be the name of the directory to copy the data to.
523 * @param filter_cb Possible to deny the move of some files/directories.
524 * @param progress_cb Callback called to know the progress of the copy.
525 * @param done_cb Callback called when the copy is done.
526 * @param error_cb Callback called when something goes wrong.
527 * @param data Unmodified user data passed to callbacks
528 * @return A reference to the I/O operation.
529 *
530 * @return an Eio_File pointer, handler to the copy operation, can be used to cancel the operation
531 *
532 * This function will copy a directory and all its content from source to dest.
533 * It will try to use splice if possible, if not it will fallback to mmap/write.
534 * It will try to preserve access rights, but not user/group identity.
535 * Every file will be passed to the filter_cb, so it's your job to decide if you
536 * want to pass the file to the main_cb or not. Return EINA_TRUE to pass it to
537 * the main_cb or EINA_FALSE to ignore it.
538 */
539EAPI Eio_File *eio_dir_copy(const char *source,
540 const char *dest,
541 Eio_Filter_Direct_Cb filter_cb,
542 Eio_Progress_Cb progress_cb,
543 Eio_Done_Cb done_cb,
544 Eio_Error_Cb error_cb,
545 const void *data);
546
547/**
548 * @brief Remove a directory and its content asynchronously
549 * @param path Should be the name of the directory to destroy.
550 * @param filter_cb Possible to deny the move of some files/directories.
551 * @param progress_cb Callback called to know the progress of the copy.
552 * @param done_cb Callback called when the copy is done.
553 * @param error_cb Callback called when something goes wrong.
554 * @param data Unmodified user data passed to callbacks
555 * @return A reference to the I/O operation.
556 *
557 * @return an Eio_File pointer, handler to the unlink operation, can be used to cancel the operation
558 *
559 * This function will remove a directory and all its content.
560 * Every file will be passed to the filter_cb, so it's your job to decide if you
561 * want to pass the file to the main_cb or not. Return EINA_TRUE to pass it to
562 * the main_cb or EINA_FALSE to ignore it.
563 */
564EAPI Eio_File *eio_dir_unlink(const char *path,
565 Eio_Filter_Direct_Cb filter_cb,
566 Eio_Progress_Cb progress_cb,
567 Eio_Done_Cb done_cb,
568 Eio_Error_Cb error_cb,
569 const void *data);
570/**
571 * @}
572 */
573
574/**
575 * @defgroup Eio_Xattr Eio manipulation of eXtended attribute.
576 * @ingroup Eio
577 *
578 * @brief A set of function to manipulate data associated with a specific file
579 *
580 * The functions provided by this API are responsible to manage Extended
581 * attribute files. Like file authors, character encoding, checksum, etc.
582 * @{
583 */
584
585/**
586 * @brief Asynchronously list all eXtended attribute
587 * @param path The path to get the eXtended attribute from.
588 * @param filter_cb Callback called in the thread to validate the eXtended attribute.
589 * @param main_cb Callback called in the main loop for each accepted eXtended attribute.
590 * @param done_cb Callback called in the main loop when the all the eXtended attribute have been listed.
591 * @param error_cb Callback called in the main loop when something goes wrong during the listing of the eXtended attribute.
592 * @param data Unmodified user data passed to callbacks
593 * @return A reference to the I/O operation.
594 */
595EAPI Eio_File *eio_file_xattr(const char *path,
596 Eio_Filter_Cb filter_cb,
597 Eio_Main_Cb main_cb,
598 Eio_Done_Cb done_cb,
599 Eio_Error_Cb error_cb,
600 const void *data);
601
602/**
603 * @brief Define an extented attribute on a file/directory.
604 * @param path The path to set the attribute on.
605 * @param attribute The name of the attribute to define.
606 * @param xattr_int The value to link the attribute with.
607 * @param flags Whether to insert, replace or create the attribute.
608 * @param done_cb The callback called from the main loop when setxattr succeeded.
609 * @param error_cb The callback called from the main loop when setxattr failed.
610 * @param data Unmodified user data passed to callbacks
611 * @return A reference to the I/O operation.
612 *
613 * eio_file_xattr_int_set calls eina_xattr_int_set from another thread. This prevents blocking in your apps. If
614 * the writing succeeded, the done_cb will be called even if a cancel was requested, but came too late.
615 */
616EAPI Eio_File *eio_file_xattr_int_set(const char *path,
617 const char *attribute,
618 int xattr_int,
619 Eina_Xattr_Flags flags,
620 Eio_Done_Cb done_cb,
621 Eio_Error_Cb error_cb,
622 const void *data);
623
624/**
625 * @brief Define an extented attribute on a file/directory.
626 * @param path The path to set the attribute on.
627 * @param attribute The name of the attribute to define.
628 * @param xattr_double The value to link the attribute with.
629 * @param flags Whether to insert, replace or create the attribute.
630 * @param done_cb The callback called from the main loop when setxattr succeeded.
631 * @param error_cb The callback called from the main loop when setxattr failed.
632 * @param data Unmodified user data passed to callbacks
633 * @return A reference to the I/O operation.
634 *
635 * eio_file_xattr_double_set calls eina_xattr_double_set from another thread. This prevents blocking in your apps. If
636 * the writing succeeded, the done_cb will be called even if a cancel was requested, but came too late.
637 */
638EAPI Eio_File *eio_file_xattr_double_set(const char *path,
639 const char *attribute,
640 double xattr_double,
641 Eina_Xattr_Flags flags,
642 Eio_Done_Cb done_cb,
643 Eio_Error_Cb error_cb,
644 const void *data);
645/**
646 * @brief Define a string extented attribute on a file/directory.
647 * @param path The path to set the attribute on.
648 * @param attribute The name of the attribute to define.
649 * @param xattr_string The string to link the attribute with.
650 * @param flags Whether to insert, replace or create the attribute.
651 * @param done_cb The callback called from the main loop when setxattr succeeded.
652 * @param error_cb The callback called from the main loop when setxattr failed.
653 * @param data Unmodified user data passed to callbacks
654 * @return A reference to the I/O operation.
655 *
656 * eio_file_xattr_string_set calls eina_xattr_string_set from another thread. This prevents blocking in your apps. If
657 * the writing succeeded, the done_cb will be called even if a cancel was requested, but came too late.
658 */
659EAPI Eio_File *eio_file_xattr_string_set(const char *path,
660 const char *attribute,
661 const char *xattr_string,
662 Eina_Xattr_Flags flags,
663 Eio_Done_Cb done_cb,
664 Eio_Error_Cb error_cb,
665 const void *data);
666/**
667 * @brief Define an extented attribute on a file/directory.
668 * @param path The path to set the attribute on.
669 * @param attribute The name of the attribute to define.
670 * @param xattr_data The data to link the attribute with.
671 * @param xattr_size The size of the data to set.
672 * @param flags Whether to insert, replace or create the attribute.
673 * @param done_cb The callback called from the main loop when setxattr succeeded.
674 * @param error_cb The callback called from the main loop when setxattr failed.
675 * @param data Unmodified user data passed to callbacks
676 * @return A reference to the I/O operation.
677 *
678 * eio_file_xattr_set calls setxattr from another thread. This prevents blocking in your apps. If
679 * the writing succeeded, the done_cb will be called even if a cancel was requested, but came too late.
680 */
681EAPI Eio_File *eio_file_xattr_set(const char *path,
682 const char *attribute,
683 const char *xattr_data,
684 unsigned int xattr_size,
685 Eina_Xattr_Flags flags,
686 Eio_Done_Cb done_cb,
687 Eio_Error_Cb error_cb,
688 const void *data);
689
690/**
691 * @brief Retrieve the extended attribute of a file/directory.
692 * @param path The path to retrieve the extended attribute from.
693 * @param attribute The name of the attribute to retrieve.
694 * @param done_cb Callback called from the main loop when getxattr succeeded.
695 * @param error_cb Callback called from the main loop when getxattr failed or has been canceled.
696 * @param data Unmodified user data passed to callbacks
697 * @return A reference to the I/O operation.
698 *
699 * eio_file_xattr_get calls getxattr from another thread. This prevents blocking in your apps.
700 */
701EAPI Eio_File *eio_file_xattr_get(const char *path,
702 const char *attribute,
703 Eio_Done_Data_Cb done_cb,
704 Eio_Error_Cb error_cb,
705 const void *data);
706/**
707 * @brief Retrieve a extended attribute of a file/directory.
708 * @param path The path to retrieve the extended attribute from.
709 * @param attribute The name of the attribute to retrieve.
710 * @param done_cb Callback called from the main loop when getxattr succeeded.
711 * @param error_cb Callback called from the main loop when getxattr failed or has been canceled.
712 * @param data Unmodified user data passed to callbacks
713 * @return A reference to the I/O operation.
714 *
715 * eio_file_xattr_int_get calls eina_xattr_int_get from another thread. This prevents blocking in your apps.
716 */
717EAPI Eio_File *eio_file_xattr_int_get(const char *path,
718 const char *attribute,
719 Eio_Done_Int_Cb done_cb,
720 Eio_Error_Cb error_cb,
721 const void *data);
722/**
723 * @brief Retrieve a extended attribute of a file/directory.
724 * @param path The path to retrieve the extended attribute from.
725 * @param attribute The name of the attribute to retrieve.
726 * @param done_cb Callback called from the main loop when getxattr succeeded.
727 * @param error_cb Callback called from the main loop when getxattr failed or has been canceled.
728 * @param data Unmodified user data passed to callbacks
729 * @return A reference to the I/O operation.
730 *
731 * eio_file_xattr_double_get calls eina_xattr_double_get from another thread. This prevents blocking in your apps.
732 */
733EAPI Eio_File *eio_file_xattr_double_get(const char *path,
734 const char *attribute,
735 Eio_Done_Double_Cb done_cb,
736 Eio_Error_Cb error_cb,
737 const void *data);
738/**
739 * @brief Retrieve a string extended attribute of a file/directory.
740 * @param path The path to retrieve the extended attribute from.
741 * @param attribute The name of the attribute to retrieve.
742 * @param done_cb Callback called from the main loop when getxattr succeeded.
743 * @param error_cb Callback called from the main loop when getxattr failed or has been canceled.
744 * @param data Unmodified user data passed to callbacks
745 * @return A reference to the I/O operation.
746 *
747 * eio_file_xattr_string_get calls eina_xattr_string_get from another thread. This prevents blocking in your apps.
748 */
749EAPI Eio_File *eio_file_xattr_string_get(const char *path,
750 const char *attribute,
751 Eio_Done_String_Cb done_cb,
752 Eio_Error_Cb error_cb,
753 const void *data);
754
755/**
756 * @}
757 */
758
759/**
760 * @defgroup Eio_Helper Eio Reference helper API
761 * @ingroup Eio
762 *
763 * @brief This are helper provided around core Eio API.
764 *
765 * This set of functions do provide helper to work around data
766 * provided by Eio without the need to look at system header.
767 *
768 * @{
769 */
770
771
772/**
773 * @brief Initialize eio and all its required submodule.
774 * @return the current number of eio users.
775 */
776EAPI int eio_init(void);
777
778/**
779 * @brief Shutdown eio and all its submodule if possible.
780 * @return the number of pending users of eio.
781 */
782EAPI int eio_shutdown(void);
783
784/**
785 * @brief Set the limit to the maximum amount of memory used
786 * @param limit The actual limit to set.
787 *
788 * Eio work by burst, allocating memory in a thread and moving it
789 * back to the main loop. This result in quite some huge memory
790 * usage if the main loop is to slow to cope with the speed of the
791 * thread. By setting this limit, the thread will block until
792 * enough memory has been freed to be below the limit again.
793 *
794 * By default no limit is set and any value < 0 will mean no limit.
795 *
796 * @note You should give at least a reasonable amount of memory or
797 * the thread might stall.
798 * @since 1.10
799 */
800EAPI void eio_memory_burst_limit_set(size_t limit);
801
802/**
803 * @brief Get the actual limit to the maximum amount of memory used
804 * @return The current limit being set.
805 *
806 * @since 1.10
807 * @see eio_memory_burst_limit_set
808 */
809EAPI size_t eio_memory_burst_limit_get(void);
810
811/**
812 * @brief Return the container during EIO operation
813 * @param ls The asynchronous I/O operation to retrieve container from.
814 * @return NULL if not available, a DIRP if it is.
815 *
816 * This is only available and make sense in the thread callback, not in
817 * the mainloop.
818 */
819EAPI void *eio_file_container_get(Eio_File *ls);
820
821/**
822 * @brief Cancel any Eio_File.
823 * @param ls The asynchronous I/O operation to cancel.
824 * @return EINA_FALSE if the destruction is delayed, EINA_TRUE if it's done.
825 *
826 * This will cancel any kind of I/O operation and cleanup the mess. This means
827 * that it could take time to cancel an I/O.
828 */
829EAPI Eina_Bool eio_file_cancel(Eio_File *ls);
830
831/**
832 * @brief Check if an Eio_File operation has been cancelled.
833 * @param ls The asynchronous I/O operation to check.
834 * @return EINA_TRUE if it was canceled, EINA_FALSE other wise.
835 *
836 * In case of an error it also return EINA_TRUE.
837 */
838EAPI Eina_Bool eio_file_check(Eio_File *ls);
839
840/**
841 * @brief Associate data with the current filtered file.
842 * @param ls The Eio_File ls request currently calling the filter callback.
843 * @param key The key to associate data to.
844 * @param data The data to associate the data to.
845 * @param free_cb Optionally a function to call to free the associated data,
846 * @p data is passed as the callback data parameter. If no @p free_cb is provided
847 * the user @p data remains untouched.
848 * @return EINA_TRUE if insertion was fine.
849 *
850 * This function can only be safely called from within the filter callback.
851 * If you don't need to copy the key around you can use @ref eio_file_associate_direct_add
852 */
853EAPI Eina_Bool eio_file_associate_add(Eio_File *ls,
854 const char *key,
855 const void *data, Eina_Free_Cb free_cb);
856
857/**
858 * @brief Associate data with the current filtered file.
859 * @param ls The Eio_File ls request currently calling the filter callback.
860 * @param key The key to associate data to (will not be copied, and the pointer will not be used as long as the file is not notified).
861 * @param data The data to associate the data to.
862 * @param free_cb The function to call to free the associated data, @p free_cb will be called if not specified.
863 * @return EINA_TRUE if insertion was fine.
864 *
865 * This function can only be safely called from within the filter callback.
866 * If you need eio to make a proper copy of the @p key to be safe use
867 * @ref eio_file_associate_add instead.
868 */
869EAPI Eina_Bool eio_file_associate_direct_add(Eio_File *ls,
870 const char *key,
871 const void *data, Eina_Free_Cb free_cb);
872
873/**
874 * @brief Get the data associated during the filter callback inside the main loop
875 * @param ls The Eio_File ls request currently calling the notify callback.
876 * @param key The key pointing to the data to retrieve.
877 * @return the data associated with the key or @p NULL if not found.
878 */
879EAPI void *eio_file_associate_find(Eio_File *ls, const char *key);
880
881/**
882 * @}
883 */
884
885/**
886 *
887 */
888
889/**
890 * @defgroup Eio_Map Manipulate an Eina_File asynchronously
891 * @ingroup Eio
892 *
893 * @brief This function helps when manipulating a file asynchronously.
894 *
895 * These set of functions work on top of Eina_File and Ecore_Thread to
896 * do basic operations on a file, like opening, closing and mapping a file to
897 * memory.
898 * @{
899 */
900
901/**
902 * @brief Asynchronously open a file.
903 * @param name The file to open.
904 * @param shared If it's a shared memory file.
905 * @param open_cb Callback called in the main loop when the file has been successfully opened.
906 * @param error_cb Callback called in the main loop when the file couldn't be opened.
907 * @param data Unmodified user data passed to callbacks
908 * @return Pointer to the file if successful or NULL otherwise.
909 *
910 */
911EAPI Eio_File *eio_file_open(const char *name, Eina_Bool shared,
912 Eio_Open_Cb open_cb,
913 Eio_Error_Cb error_cb,
914 const void *data);
915
916/**
917 * @brief Asynchronously close a file.
918 * @param f The file to close.
919 * @param done_cb Callback called in the main loop when the file has been successfully closed.
920 * @param error_cb Callback called in the main loop when the file couldn't be closed.
921 * @param data Unmodified user data passed to callbacks
922 * @return Pointer to the file if successful or NULL otherwise.
923 */
924EAPI Eio_File *eio_file_close(Eina_File *f,
925 Eio_Done_Cb done_cb,
926 Eio_Error_Cb error_cb,
927 const void *data);
928
929/**
930 * @brief Asynchronously map a file in memory.
931 * @param f The file to map.
932 * @param rule The rule to apply to the map.
933 * @param filter_cb Callback called in the thread to validate the content of the map.
934 * @param map_cb Callback called in the main loop when the file has been successfully mapped.
935 * @param error_cb Callback called in the main loop when the file can't be mapped.
936 * @param data Unmodified user data passed to callbacks
937 * @return Pointer to the file if successful or NULL otherwise.
938 *
939 * The container of the Eio_File is the Eina_File.
940 */
941EAPI Eio_File *eio_file_map_all(Eina_File *f,
942 Eina_File_Populate rule,
943 Eio_Filter_Map_Cb filter_cb,
944 Eio_Map_Cb map_cb,
945 Eio_Error_Cb error_cb,
946 const void *data);
947
948/**
949 * @brief Asynchronously map a part of a file in memory.
950 * @param f The file to map.
951 * @param rule The rule to apply to the map.
952 * @param offset The offset inside the file
953 * @param length The length of the memory to map
954 * @param filter_cb Callback called in the thread to validate the content of the map.
955 * @param map_cb Callback called in the main loop when the file has been successfully mapped.
956 * @param error_cb Callback called in the main loop when the file can't be mapped.
957 * @param data Unmodified user data passed to callbacks
958 * @return Pointer to the file if successful or NULL otherwise.
959 *
960 * The container of the Eio_File is the Eina_File.
961 */
962EAPI Eio_File *eio_file_map_new(Eina_File *f,
963 Eina_File_Populate rule,
964 unsigned long int offset,
965 unsigned long int length,
966 Eio_Filter_Map_Cb filter_cb,
967 Eio_Map_Cb map_cb,
968 Eio_Error_Cb error_cb,
969 const void *data);
970
971/**
972 * @}
973 */
974
975/**
976 * @defgroup Eio_Eet Eio asynchronous API for Eet file.
977 * @ingroup Eio
978 *
979 * @brief This set of functions help in the asynchronous use of Eet
980 *
981 * @{
982 */
983
984/**
985 * @brief Open an eet file on disk, and returns a handle to it asynchronously.
986 * @param filename The file path to the eet file. eg: @c "/tmp/file.eet".
987 * @param mode The mode for opening. Either EET_FILE_MODE_READ,
988 * EET_FILE_MODE_WRITE or EET_FILE_MODE_READ_WRITE.
989 * @param eet_cb The callback to call when the file has been successfully opened.
990 * @param error_cb Callback called in the main loop when the file can't be opened.
991 * @param data Unmodified user data passed to callbacks
992 * @return NULL in case of a failure.
993 *
994 * This function calls eet_open() from another thread using Ecore_Thread.
995 */
996EAPI Eio_File *eio_eet_open(const char *filename,
997 Eet_File_Mode mode,
998 Eio_Eet_Open_Cb eet_cb,
999 Eio_Error_Cb error_cb,
1000 const void *data);
1001/**
1002 * @brief Close an eet file handle and flush pending writes asynchronously.
1003 * @param ef A valid eet file handle.
1004 * @param done_cb Callback called from the main loop when the file has been closed.
1005 * @param error_cb Callback called in the main loop when the file can't be closed.
1006 * @param data Unmodified user data passed to callbacks
1007 * @return NULL in case of a failure.
1008 *
1009 * This function will call eet_close() from another thread by
1010 * using Ecore_Thread. You should assume that the Eet_File is dead after this
1011 * function is called.
1012 */
1013EAPI Eio_File *eio_eet_close(Eet_File *ef,
1014 Eio_Done_Cb done_cb,
1015 Eio_Eet_Error_Cb error_cb,
1016 const void *data);
1017
1018/**
1019 * @brief Sync content of an eet file handle, flushing pending writes asynchronously.
1020 * @param ef A valid eet file handle.
1021 * @param done_cb Callback called from the main loop when the file has been synced.
1022 * @param error_cb Callback called in the main loop when the file can't be synced.
1023 * @param data Unmodified user data passed to callbacks
1024 * @return NULL in case of a failure.
1025 *
1026 * This function will call eet_sync() from another thread. As long as the done_cb or
1027 * error_cb haven't be called, you must keep @p ef open.
1028 */
1029EAPI Eio_File *eio_eet_sync(Eet_File *ef,
1030 Eio_Done_Cb done_cb,
1031 Eio_Eet_Error_Cb error_cb,
1032 const void *data);
1033
1034/**
1035 * @brief Write a data structure from memory and store in an eet file
1036 * using a cipher asynchronously.
1037 * @param ef The eet file handle to write to.
1038 * @param edd The data descriptor to use when encoding.
1039 * @param name The key to store the data under in the eet file.
1040 * @param cipher_key The key to use as cipher.
1041 * @param write_data A pointer to the data structure to save and encode.
1042 * @param compress Compression flags for storage.
1043 * @param done_cb Callback called from the main loop when the data has been put in the Eet_File.
1044 * @param error_cb Callback called in the main loop when the file can't be written.
1045 * @param user_data Private data given to each callback.
1046 * @return NULL in case of a failure.
1047 */
1048EAPI Eio_File *eio_eet_data_write_cipher(Eet_File *ef,
1049 Eet_Data_Descriptor *edd,
1050 const char *name,
1051 const char *cipher_key,
1052 void *write_data,
1053 int compress,
1054 Eio_Done_Int_Cb done_cb,
1055 Eio_Error_Cb error_cb,
1056 const void *user_data);
1057
1058/**
1059 * @brief Read a data structure from an eet file and decodes it using a cipher asynchronously.
1060 * @param ef The eet file handle to read from.
1061 * @param edd The data descriptor handle to use when decoding.
1062 * @param name The key the data is stored under in the eet file.
1063 * @param cipher_key The key to use as cipher.
1064 * @param done_cb Callback called from the main loop when the data has been read and decoded.
1065 * @param error_cb Callback called in the main loop when the data can't be read.
1066 * @param data Unmodified user data passed to callbacks
1067 * @return NULL in case of a failure.
1068 */
1069EAPI Eio_File *eio_eet_data_read_cipher(Eet_File *ef,
1070 Eet_Data_Descriptor *edd,
1071 const char *name,
1072 const char *cipher_key,
1073 Eio_Done_ERead_Cb done_cb,
1074 Eio_Error_Cb error_cb,
1075 const void *data);
1076
1077/**
1078 * @brief Write image data to the named key in an eet file asynchronously.
1079 * @param ef A valid eet file handle opened for writing.
1080 * @param name Name of the entry. eg: "/base/file_i_want".
1081 * @param cipher_key The key to use as cipher.
1082 * @param write_data A pointer to the image pixel data.
1083 * @param w The width of the image in pixels.
1084 * @param h The height of the image in pixels.
1085 * @param alpha The alpha channel flag.
1086 * @param compress The compression amount.
1087 * @param quality The quality encoding amount.
1088 * @param lossy The lossiness flag.
1089 * @param done_cb Callback called from the main loop when the data has been put in the Eet_File.
1090 * @param error_cb Callback called in the main loop when the file can't be written.
1091 * @param user_data Private data given to each callback.
1092 * @return NULL in case of a failure.
1093 */
1094EAPI Eio_File *eio_eet_data_image_write_cipher(Eet_File *ef,
1095 const char *name,
1096 const char *cipher_key,
1097 void *write_data,
1098 unsigned int w,
1099 unsigned int h,
1100 int alpha,
1101 int compress,
1102 int quality,
1103 int lossy,
1104 Eio_Done_Int_Cb done_cb,
1105 Eio_Error_Cb error_cb,
1106 const void *user_data);
1107
1108/**
1109 * @brief Read a specified entry from an eet file and return data
1110 * @param ef A valid eet file handle opened for reading.
1111 * @param name Name of the entry. eg: "/base/file_i_want".
1112 * @param done_cb Callback called from the main loop when the data has been read.
1113 * @param error_cb Callback called in the main loop when the data can't be read.
1114 * @param data Unmodified user data passed to callbacks
1115 * @return NULL in case of a failure.
1116 */
1117EAPI Eio_File *eio_eet_read_direct(Eet_File *ef,
1118 const char *name,
1119 Eio_Done_Data_Cb done_cb,
1120 Eio_Error_Cb error_cb,
1121 const void *data);
1122
1123/**
1124 * @brief Read a specified entry from an eet file and return data
1125 * @param ef A valid eet file handle opened for reading.
1126 * @param name Name of the entry. eg: "/base/file_i_want".
1127 * @param cipher_key The key to use as cipher.
1128 * @param done_cb Callback called from the main loop when the data has been read.
1129 * @param error_cb Callback called in the main loop when the data can't be read.
1130 * @param data Unmodified user data passed to callbacks
1131 * @return NULL in case of a failure.
1132 */
1133EAPI Eio_File *eio_eet_read_cipher(Eet_File *ef,
1134 const char *name,
1135 const char *cipher_key,
1136 Eio_Done_Read_Cb done_cb,
1137 Eio_Error_Cb error_cb,
1138 const void *data);
1139
1140/**
1141 * @brief Write a specified entry to an eet file handle using a cipher.
1142 * @param ef A valid eet file handle opened for writing.
1143 * @param name Name of the entry. eg: "/base/file_i_want".
1144 * @param write_data Pointer to the data to be stored.
1145 * @param size Length in bytes in the data to be stored.
1146 * @param compress Compression flags (1 == compress, 0 = don't compress).
1147 * @param cipher_key The key to use as cipher.
1148 * @param done_cb Callback called from the main loop when the data has been put in the Eet_File.
1149 * @param error_cb Callback called in the main loop when the file can't be written.
1150 * @param user_data Private data given to each callback.
1151 * @return NULL in case of a failure.
1152 */
1153EAPI Eio_File *eio_eet_write_cipher(Eet_File *ef,
1154 const char *name,
1155 void *write_data,
1156 int size,
1157 int compress,
1158 const char *cipher_key,
1159 Eio_Done_Int_Cb done_cb,
1160 Eio_Error_Cb error_cb,
1161 const void *user_data);
1162
1163/**
1164 * @}
1165 */
1166
1167/**
1168 * @defgroup Eio_Monitor Eio file and directory monitoring API
1169 * @ingroup Eio
1170 *
1171 * @brief These function monitor changes in directories and files
1172 *
1173 * These functions use the best available method to monitor changes on a specified directory
1174 * or file. They send ecore events when changes occur, and they maintain internal refcounts to
1175 * reduce resource consumption on duplicate monitor targets.
1176 *
1177 * @{
1178 */
1179
1180EAPI extern int EIO_MONITOR_FILE_CREATED; /**< A new file was created in a watched directory */
1181EAPI extern int EIO_MONITOR_FILE_DELETED; /**< A watched file was deleted, or a file in a watched directory was deleted */
1182EAPI extern int EIO_MONITOR_FILE_MODIFIED; /**< A file was modified in a watched directory */
1183EAPI extern int EIO_MONITOR_FILE_CLOSED; /**< A file was closed in a watched directory. This event is never sent on Windows and OSX */
1184EAPI extern int EIO_MONITOR_DIRECTORY_CREATED; /**< A new directory was created in a watched directory */
1185EAPI extern int EIO_MONITOR_DIRECTORY_DELETED; /**< A directory has been deleted: this can be either a watched directory or one of its subdirectories */
1186EAPI extern int EIO_MONITOR_DIRECTORY_MODIFIED; /**< A directory has been modified in a watched directory */
1187EAPI extern int EIO_MONITOR_DIRECTORY_CLOSED; /**< A directory has been closed in a watched directory. This event is never sent on Windows and OSX */
1188EAPI extern int EIO_MONITOR_SELF_RENAME; /**< The monitored path has been renamed, an error could happen just after if the renamed path doesn't exist. This event is never sent on OSX */
1189EAPI extern int EIO_MONITOR_SELF_DELETED; /**< The monitored path has been removed. This event is never sent on OSX */
1190EAPI extern int EIO_MONITOR_ERROR; /**< During operation the monitor failed and will no longer work. eio_monitor_del must be called on it. */
1191
1192typedef struct _Eio_Monitor Eio_Monitor;
1193
1194typedef struct _Eio_Monitor_Error Eio_Monitor_Error;
1195typedef struct _Eio_Monitor_Event Eio_Monitor_Event;
1196
1197struct _Eio_Monitor_Error
1198{
1199 Eio_Monitor *monitor;
1200 int error;
1201};
1202
1203struct _Eio_Monitor_Event
1204{
1205 Eio_Monitor *monitor;
1206 const char *filename;
1207};
1208
1209/**
1210 * @brief Adds a file/directory to monitor (inotify mechanism)
1211 * @param path file/directory to monitor
1212 * @return NULL in case of a failure or a pointer to the monitor in case of
1213 * success.
1214 *
1215 * This function will add the given path to its internal
1216 * list of files to monitor. It utilizes the inotify mechanism
1217 * introduced in kernel 2.6.13 for passive monitoring.
1218 */
1219EAPI Eio_Monitor *eio_monitor_add(const char *path);
1220
1221/**
1222 * @brief Adds a file/directory to monitor
1223 * @param path file/directory to monitor
1224 * @return NULL in case of a failure or a pointer to the monitor in case of
1225 * success.
1226 * @warning Do NOT pass non-stringshared strings to this function!
1227 * If you don't know what this means, use eio_monitor_add().
1228 *
1229 * This fuction is just like eio_monitor_add(), however the string passed by
1230 * argument must be created using eina_stringshare_add().
1231 */
1232EAPI Eio_Monitor *eio_monitor_stringshared_add(const char *path);
1233
1234/**
1235 * @brief Deletes a path from the “watched” list
1236 * @param monitor The Eio_Monitor you want to stop watching.
1237 * It can only be an Eio_Monitor returned to you from calling
1238 * eio_monitor_add() or eio_monitor_stringshared_add()
1239 */
1240EAPI void eio_monitor_del(Eio_Monitor *monitor);
1241
1242/**
1243 * @brief returns the path being watched by the given
1244 * Eio_Monitor.
1245 * @param monitor Eio_Monitor to return the path of
1246 * @return The stringshared path belonging to @p monitor
1247 */
1248EAPI const char *eio_monitor_path_get(Eio_Monitor *monitor);
1249
1250/**
1251 * @}
1252 */
1253
1254#ifdef __cplusplus
1255}
1256#endif
diff --git a/src/lib/eio/eio_job.c b/src/lib/eio/eio_job.c
new file mode 100644
index 0000000000..e9fb2f795f
--- /dev/null
+++ b/src/lib/eio/eio_job.c
@@ -0,0 +1,586 @@
1/* EIO - EFL data type library
2 * Copyright (C) 2016 Enlightenment Developers:
3 * Lauro Moura <lauromoura@expertisesolutions.com.br>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifdef HAVE_CONFIG_H
21# include <config.h>
22#endif
23
24
25#include <Eo.h>
26#include "Eio.h"
27#include "eio_job_private.h"
28
29typedef Eio_File* (*Eio_Job_Direct_Ls_Func)(const char *path, Eio_Filter_Direct_Cb, Eio_Main_Direct_Cb, Eio_Done_Cb, Eio_Error_Cb, const void *data);
30
31typedef struct _Job_Closure Job_Closure;
32struct _Job_Closure
33{
34 Eo *object;
35 Eio_Job_Data *pdata;
36 Eina_Promise_Owner *promise;
37 Eio_File *file;
38 Eina_Bool delete_me;
39 void *delayed_arg;
40 Eio_Job_Direct_Ls_Func direct_func; // Used when dispatching direct ls funcs.
41};
42
43/* Helper functions */
44
45static Job_Closure *
46_job_closure_create(Eo *obj, Eio_Job_Data *pdata, Eina_Promise_Owner *owner)
47{
48 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
49 EINA_SAFETY_ON_NULL_RETURN_VAL(pdata, NULL);
50 EINA_SAFETY_ON_NULL_RETURN_VAL(owner, NULL);
51
52 Job_Closure *closure = malloc(sizeof(Job_Closure));
53
54 if (!closure)
55 {
56 EINA_LOG_CRIT("Failed to allocate memory.");
57 return 0;
58 }
59
60 closure->object = eo_ref(obj);
61 closure->pdata = pdata;
62 closure->promise = owner;
63 closure->file = NULL; // Will be set once the Eio operation is under way
64 closure->delete_me = EINA_FALSE;
65 closure->delayed_arg = NULL;
66 closure->direct_func = NULL;
67
68 pdata->operations = eina_list_prepend(pdata->operations, closure);
69
70 return closure;
71}
72
73static void
74_job_closure_del(Job_Closure *closure)
75{
76 EINA_SAFETY_ON_NULL_RETURN(closure);
77 Eio_Job_Data *pdata = closure->pdata;
78 if (pdata)
79 pdata->operations = eina_list_remove(pdata->operations, closure);
80
81 eo_unref(closure->object);
82
83 if (closure->delayed_arg)
84 free(closure->delayed_arg);
85
86 free(closure);
87}
88
89static void
90_file_error_cb(void *data, Eio_File *handler EINA_UNUSED, int error)
91{
92 Job_Closure *operation = data;
93
94 EINA_SAFETY_ON_NULL_RETURN(operation);
95 EINA_SAFETY_ON_NULL_RETURN(operation->promise);
96
97 eina_promise_owner_error_set(operation->promise, error);
98
99 _job_closure_del(operation);
100}
101
102/* Basic listing callbacks */
103
104static Eina_Bool
105_file_ls_filter_cb_helper(const Eo_Event_Description *event, void *data, const char *file)
106{
107 Job_Closure *operation = data;
108
109 EINA_SAFETY_ON_NULL_RETURN_VAL(operation, EINA_FALSE);
110 EINA_SAFETY_ON_NULL_RETURN_VAL(operation->pdata, EINA_FALSE);
111
112 Eio_Filter_Name_Data* event_info = malloc(sizeof(Eio_Filter_Name_Data));
113
114 EINA_SAFETY_ON_NULL_RETURN_VAL(event_info, EINA_FALSE);
115
116 event_info->file = file;
117 event_info->filter = EINA_FALSE;
118
119 eo_event_callback_call(operation->pdata->object, event, event_info);
120
121 Eina_Bool filter = event_info->filter;
122
123 free(event_info);
124
125 return filter;
126}
127
128static Eina_Bool
129_file_ls_filter_xattr_cb(void *data, Eio_File *handler EINA_UNUSED, const char *file)
130{
131 return _file_ls_filter_cb_helper(EIO_JOB_EVENT_XATTR, data, file);
132}
133
134static Eina_Bool
135_file_ls_filter_named_cb(void *data, Eio_File *handler EINA_UNUSED, const char *file)
136{
137 return _file_ls_filter_cb_helper(EIO_JOB_EVENT_FILTER_NAME, data, file);
138}
139
140static void
141_file_ls_main_cb(void *data, Eio_File *handler EINA_UNUSED, const char *file)
142{
143 Job_Closure *operation = data;
144 EINA_SAFETY_ON_NULL_RETURN(operation);
145 EINA_SAFETY_ON_NULL_RETURN(operation->promise);
146
147 eina_promise_owner_progress(operation->promise, (void*)file);
148}
149
150static void
151_file_done_cb(void *data, Eio_File *handler EINA_UNUSED)
152{
153 Job_Closure *operation = data;
154
155 EINA_SAFETY_ON_NULL_RETURN(operation);
156 EINA_SAFETY_ON_NULL_RETURN(operation->promise);
157
158 // Placeholder value. We just want the callback to be called.
159 Eina_Bool result = EINA_TRUE;
160 eina_promise_owner_value_set(operation->promise, &result, NULL);
161
162 _job_closure_del(operation);
163}
164
165static void
166_free_xattr_data(Eio_Xattr_Data *value)
167{
168 EINA_SAFETY_ON_NULL_RETURN(value);
169 if (value->data)
170 free((void*)value->data);
171}
172
173static void
174_file_done_data_cb(void *data, Eio_File *handler EINA_UNUSED, const char *attr_data, unsigned int size)
175{
176 Job_Closure *operation = data;
177 Eio_Xattr_Data *ret_data = NULL;
178
179 EINA_SAFETY_ON_NULL_RETURN(operation);
180 EINA_SAFETY_ON_NULL_RETURN(operation->promise);
181
182 ret_data = malloc(sizeof(Eio_Xattr_Data));
183
184 if (!ret_data)
185 {
186 EINA_LOG_CRIT("Failed to create promise result data.");
187 return;
188 }
189
190
191 ret_data->data = calloc(sizeof(char), size + 1);
192 strcpy((char*)ret_data->data, attr_data);
193 ret_data->size = size;
194
195 eina_promise_owner_value_set(operation->promise, ret_data, (Eina_Promise_Free_Cb)&_free_xattr_data);
196
197 free(ret_data);
198
199 _job_closure_del(operation);
200}
201
202/* Direct listing callbacks */
203
204static Eina_Bool
205_file_direct_ls_filter_cb(void *data, Eio_File *handle EINA_UNUSED, const Eina_File_Direct_Info *info)
206{
207 Job_Closure *operation = data;
208
209 EINA_SAFETY_ON_NULL_RETURN_VAL(operation, EINA_FALSE);
210 EINA_SAFETY_ON_NULL_RETURN_VAL(operation->pdata, EINA_FALSE);
211
212 Eio_Filter_Direct_Data* event_info = malloc(sizeof(Eio_Filter_Direct_Data));
213
214 EINA_SAFETY_ON_NULL_RETURN_VAL(event_info, EINA_FALSE);
215
216 event_info->info = info;
217 event_info->filter = EINA_FALSE;
218
219 eo_event_callback_call(operation->pdata->object, EIO_JOB_EVENT_FILTER_DIRECT, event_info);
220
221 Eina_Bool filter = event_info->filter;
222
223 free(event_info);
224
225 return filter;
226}
227
228static void
229_file_direct_ls_main_cb(void *data, Eio_File *handler EINA_UNUSED, const Eina_File_Direct_Info *info)
230{
231 Job_Closure *operation = data;
232 EINA_SAFETY_ON_NULL_RETURN(operation);
233 EINA_SAFETY_ON_NULL_RETURN(operation->promise);
234
235 eina_promise_owner_progress(operation->promise, (void*)info);
236}
237
238static void
239_ls_direct_notify_start(void* data, Eina_Promise_Owner *promise)
240{
241 Job_Closure *operation_data = (Job_Closure*)data;
242 char* path = operation_data->delayed_arg;
243
244 Eio_File *handle = operation_data->direct_func(path,
245 _file_direct_ls_filter_cb,
246 _file_direct_ls_main_cb,
247 _file_done_cb,
248 _file_error_cb,
249 operation_data);
250 operation_data->file = handle;
251
252 promise->progress_notify = NULL;
253}
254
255static void
256_free_notify_start_data(void *data)
257{
258 Job_Closure *operation_data = (Job_Closure*)data;
259 if (!operation_data->delayed_arg)
260 return;
261 free(operation_data->delayed_arg);
262 operation_data->delayed_arg = NULL;
263}
264
265static void
266_ls_notify_start(void *data, Eina_Promise_Owner* promise)
267{
268 Job_Closure *operation_data = (Job_Closure*)data;
269 char* path = operation_data->delayed_arg;
270
271 Eio_File *handle = eio_file_ls(path,
272 _file_ls_filter_named_cb,
273 _file_ls_main_cb,
274 _file_done_cb,
275 _file_error_cb,
276 operation_data);
277 operation_data->file = handle;
278
279 promise->progress_notify = NULL; // Don't ever think about calling me again...
280}
281
282static void
283_xattr_notify_start(void *data, Eina_Promise_Owner *promise)
284{
285 Job_Closure *operation_data = (Job_Closure*)data;
286 char* path = operation_data->delayed_arg;
287
288 Eio_File *handle = eio_file_xattr(path,
289 _file_ls_filter_xattr_cb,
290 _file_ls_main_cb,
291 _file_done_cb,
292 _file_error_cb,
293 operation_data);
294 operation_data->file = handle;
295
296 promise->progress_notify = NULL; // Don't ever think about calling me again...
297}
298
299static void
300_job_direct_ls_helper(Eio_Job_Direct_Ls_Func ls_func,
301 Eo* obj,
302 Eio_Job_Data *pd,
303 const char *path,
304 Eina_Promise_Owner *promise)
305{
306 Job_Closure *operation_data = _job_closure_create(obj, pd, promise);
307
308 if (!operation_data)
309 {
310 EINA_LOG_CRIT("Failed to create eio job operation data.");
311 return;
312 }
313
314 operation_data->delayed_arg = (char*)calloc(sizeof(char), strlen(path) + 1);
315 strcpy(operation_data->delayed_arg, path);
316
317 operation_data->direct_func = ls_func;
318
319 eina_promise_owner_progress_notify(promise,
320 _ls_direct_notify_start,
321 operation_data,
322 _free_notify_start_data);
323}
324
325/* Method implementations */
326
327void
328_eio_job_file_direct_ls(Eo *obj,
329 Eio_Job_Data *pd,
330 const char *path,
331 Eina_Promise_Owner *promise)
332{
333 _job_direct_ls_helper(&eio_file_direct_ls, obj, pd, path, promise);
334}
335
336void
337_eio_job_file_stat_ls(Eo *obj,
338 Eio_Job_Data *pd,
339 const char *path,
340 Eina_Promise_Owner *promise)
341{
342 _job_direct_ls_helper(&eio_file_stat_ls, obj, pd, path, promise);
343}
344
345void
346_eio_job_dir_stat_ls(Eo *obj,
347 Eio_Job_Data *pd,
348 const char *path,
349 Eina_Promise_Owner *promise)
350{
351 _job_direct_ls_helper(&eio_dir_stat_ls, obj, pd, path, promise);
352}
353
354void
355_eio_job_dir_direct_ls(Eo *obj EINA_UNUSED,
356 Eio_Job_Data *pd EINA_UNUSED,
357 const char *path,
358 Eina_Promise_Owner *promise EINA_UNUSED)
359{
360 // Had to add the cast as dir_direct differs in the filter callback constness of one of
361 // its arguments.
362 _job_direct_ls_helper((Eio_Job_Direct_Ls_Func)&eio_dir_direct_ls, obj, pd, path, promise);
363}
364
365void
366_eio_job_file_ls(Eo *obj,
367 Eio_Job_Data *pd,
368 const char *path,
369 Eina_Promise_Owner *promise)
370{
371 Job_Closure *operation_data = _job_closure_create(obj, pd, promise);
372
373 if (!operation_data)
374 {
375 EINA_LOG_CRIT("Failed to create eio job operation data.");
376 return;
377 }
378
379 operation_data->delayed_arg = (char*)calloc(sizeof(char), strlen(path) + 1);
380 strcpy(operation_data->delayed_arg, path);
381
382 eina_promise_owner_progress_notify(promise,
383 _ls_notify_start,
384 operation_data,
385 _free_notify_start_data);
386}
387
388/* Stat function */
389
390static void
391_file_stat_done_cb(void *data, Eio_File *handle EINA_UNUSED, const Eina_Stat *stat)
392{
393 Job_Closure *operation = data;
394
395 EINA_SAFETY_ON_NULL_RETURN(operation);
396 EINA_SAFETY_ON_NULL_RETURN(operation->promise);
397
398 // Placeholder value. We just want the callback to be called.
399 eina_promise_owner_value_set(operation->promise, &stat, NULL);
400
401 _job_closure_del(operation);
402}
403
404void
405_eio_job_file_direct_stat(Eo *obj,
406 Eio_Job_Data *pd,
407 const char *path,
408 Eina_Promise_Owner *promise)
409{
410 Job_Closure *operation_data = _job_closure_create(obj, pd, promise);
411
412 if (!operation_data)
413 {
414 EINA_LOG_CRIT("Failed to create eio job operation data.");
415 return;
416 }
417
418 Eio_File *handle = eio_file_direct_stat(path,
419 _file_stat_done_cb,
420 _file_error_cb,
421 operation_data);
422 operation_data->file = handle;
423}
424
425/* eXtended attribute manipulation */
426
427void
428_eio_job_file_xattr(Eo *obj,
429 Eio_Job_Data *pd,
430 const char *path,
431 Eina_Promise_Owner *promise)
432{
433 Job_Closure *operation_data = _job_closure_create(obj, pd, promise);
434
435 if (!operation_data)
436 {
437 EINA_LOG_CRIT("Failed to create eio job operation data.");
438 return;
439 }
440
441 operation_data->delayed_arg = (char*)calloc(sizeof(char), strlen(path) + 1);
442 strcpy(operation_data->delayed_arg, path);
443
444 eina_promise_owner_progress_notify(promise,
445 _xattr_notify_start,
446 operation_data,
447 _free_notify_start_data);
448}
449
450void
451_eio_job_file_xattr_set(Eo *obj,
452 Eio_Job_Data *pd,
453 const char *path,
454 const char *attribute,
455 const char *xattr_data,
456 unsigned int xattr_size,
457 Eina_Xattr_Flags flags,
458 Eina_Promise_Owner *promise)
459{
460 Job_Closure *operation_data = _job_closure_create(obj, pd, promise);
461
462 if (!operation_data)
463 {
464 EINA_LOG_CRIT("Failed to create eio job operation data.");
465 return;
466 }
467
468 Eio_File *handle = eio_file_xattr_set(path,
469 attribute,
470 xattr_data,
471 xattr_size,
472 flags,
473 _file_done_cb,
474 _file_error_cb,
475 operation_data);
476 operation_data->file = handle;
477}
478
479void
480_eio_job_file_xattr_get(Eo *obj,
481 Eio_Job_Data *pd,
482 const char *path,
483 const char *attribute,
484 Eina_Promise_Owner *promise)
485{
486 Job_Closure *operation_data = _job_closure_create(obj, pd, promise);
487
488 if (!operation_data)
489 {
490 EINA_LOG_CRIT("Failed to create eio job operation data.");
491 return;
492 }
493
494 Eio_File *handle = eio_file_xattr_get(path,
495 attribute,
496 _file_done_data_cb,
497 _file_error_cb,
498 operation_data);
499 operation_data->file = handle;
500}
501
502/* Eina_File mapping and handling. */
503
504static void
505_file_open_open_cb(void *data, Eio_File *handler EINA_UNUSED, Eina_File *file)
506{
507 Job_Closure *operation = data;
508 EINA_SAFETY_ON_NULL_RETURN(operation);
509 EINA_SAFETY_ON_NULL_RETURN(operation->promise);
510 // FIXME On promise composition, a successfully open file would leak open
511 // another promise in the composition fails as there is no free/close
512 // function. Calling eina_file_close blocks on a lock_take call on a
513 // field of the Eina_File file.
514 eina_promise_owner_value_set(operation->promise, &file, NULL);
515
516 _job_closure_del(operation);
517}
518
519void
520_eio_job_file_open(Eo *obj,
521 Eio_Job_Data *pd,
522 const char *path,
523 Eina_Bool shared,
524 Eina_Promise_Owner *promise)
525{
526 Job_Closure *operation_data = _job_closure_create(obj, pd, promise);
527
528 if (!operation_data)
529 {
530 EINA_LOG_CRIT("Failed to create eio job operation data.");
531 return;
532 }
533
534 Eio_File *handle = eio_file_open(path, shared, _file_open_open_cb, _file_error_cb, operation_data);
535 operation_data->file = handle;
536}
537
538
539static
540void _file_close_done_cb(void *data, Eio_File *handler EINA_UNUSED)
541{
542 EINA_SAFETY_ON_NULL_RETURN(data);
543 Job_Closure *operation = data;
544 Eina_Bool result = EINA_TRUE;
545 eina_promise_owner_value_set(operation->promise, &result, NULL);
546
547 _job_closure_del(operation);
548}
549void _eio_job_file_close(Eo *obj,
550 Eio_Job_Data *pd,
551 Eina_File *file,
552 Eina_Promise_Owner *promise)
553{
554 Job_Closure *operation_data = _job_closure_create(obj, pd, promise);
555
556 if (!operation_data)
557 {
558 EINA_LOG_CRIT("Failed to create eio job operation data.");
559 return;
560 }
561
562 Eio_File *handle = eio_file_close(file, _file_close_done_cb, _file_error_cb, operation_data);
563 operation_data->file = handle;
564}
565
566void _eio_job_cancel_all(Eo *obj EINA_UNUSED, Eio_Job_Data *pd EINA_UNUSED)
567{
568 printf("%s called.\n", __FUNCTION__);
569}
570
571Eo_Base * _eio_job_eo_base_constructor(Eo *obj, Eio_Job_Data *pd EINA_UNUSED)
572{
573 obj = eo_constructor(eo_super(obj, EIO_JOB_CLASS));
574
575 pd->object = obj;
576 pd->operations = NULL;
577
578 return obj;
579}
580
581void _eio_job_eo_base_destructor(Eo *obj, Eio_Job_Data *pd EINA_UNUSED)
582{
583 eo_destructor(eo_super(obj, EIO_JOB_CLASS));
584}
585
586#include "eio_job.eo.c"
diff --git a/src/lib/eio/eio_job.eo b/src/lib/eio/eio_job.eo
new file mode 100644
index 0000000000..3a12d23e92
--- /dev/null
+++ b/src/lib/eio/eio_job.eo
@@ -0,0 +1,152 @@
1import eina_types;
2
3struct Eio.Data
4{
5 [[A structure to handle arbitrary data to be sent over Promises.]]
6 data: void *;
7 size: uint;
8}
9
10struct Eio.Filter.Direct.Data
11{
12 info: const(Eina.File.Direct.Info)*;
13 filter: bool;
14}
15
16struct Eio.Filter.Name.Data
17{
18 file: const(char)*;
19 filter: bool;
20}
21
22struct Eio.Xattr.Data
23{
24 data: const(char)*;
25 size: uint;
26}
27
28class Eio.Job (Eo.Base)
29{
30 [[Class representing an asynchronous file operation.]]
31
32 legacy_prefix: null;
33
34 methods {
35
36 // Listing operations
37 file_ls {
38 [[Lists entries in a given path.]]
39 params {
40 @in path: const(char)*;
41 @inout promise: promise<int, const(char)*>;
42 }
43 }
44
45 file_direct_ls {
46 [[Lists entries in a given path with more information.]]
47 params {
48 @in path: const(char)*;
49 @inout promise: promise<int, const(Eina_File_Direct_Info)*>;
50 }
51 }
52
53 file_stat_ls {
54 [[Lists entries in a given path with stat information.]]
55 params {
56 @in path: const(char)*;
57 @inout promise: promise<int, const(Eina_File_Direct_Info)*>;
58 }
59 }
60
61 dir_stat_ls {
62 [[Recursively list the directory content and its sub content.]]
63 params {
64 @in path: const(char)*;
65 @inout promise: promise<int, const(Eina_File_Direct_Info)*>;
66 }
67 }
68
69 dir_direct_ls {
70 [[Recursively list the directory content and its sub content.]]
71 params {
72 @in path: const(char)*;
73 @inout promise: promise<int, const(Eina_File_Direct_Info)*>;
74 }
75 }
76
77 file_direct_stat {
78 [[Get stat info on a given file/directory.]]
79 params {
80 @in path: const(char)*;
81 @inout promise: promise<const(Eina_Stat)*>; //TODO Change to a delayed promise.
82 }
83 }
84
85 // Extended attributes
86
87 file_xattr {
88 [[Lists all extended attributes asynchronously.]]
89 params {
90 @in path: const(char)*;
91 @inout promise: promise<int, const(char)*>;
92 }
93 }
94
95 file_xattr_set {
96 [[Sets a given extended attribute.]]
97 params {
98 @in path: const(char)*;
99 @in attribute: const(char)*;
100 @in xattr_data: const(char)*;
101 @in xattr_size: uint;
102 @in flags: Eina.Xattr.Flags;
103 @inout promise: promise<int>;
104 }
105 }
106
107 file_xattr_get {
108 [[Sets a given extended attribute.]]
109 params {
110 @in path: const(char)*;
111 @in attribute: const(char)*;
112 @inout promise: promise<Eio.Xattr.Data*>;
113 }
114 }
115
116 // helper api
117 file_open {
118 [[Opens a file.
119
120 The fulfilled value in the promise will be the Eina.File*.]]
121 params {
122 @in path: const(char)*;
123 @in shared: bool;
124 @inout promise: promise<Eina.File*>;
125 }
126 }
127 file_close {
128 [[Closes an open Eina.File.]]
129 params {
130 @in file: Eina.File*;
131 // Here we're just interested whether the promise was fullfilled or not. No value needed.
132 @inout promise: promise<int>;
133 }
134 }
135 cancel_all {
136 [[Cancels all pending operations on this job.]]
137 params {
138 // Shall we need some promise here?
139 }
140 }
141 }
142 events {
143 filter,name: Eio.Filter.Name.Data;
144 filter,direct: Eio.Filter.Direct.Data;
145 xattr: Eio.Filter.Name.Data;
146 }
147
148 implements {
149 Eo.Base.constructor;
150 Eo.Base.destructor;
151 }
152}
diff --git a/src/lib/eio/eio_job_private.h b/src/lib/eio/eio_job_private.h
new file mode 100644
index 0000000000..26a2a5a9b6
--- /dev/null
+++ b/src/lib/eio/eio_job_private.h
@@ -0,0 +1,12 @@
1#ifndef _EIO_FILE_PRIVATE_H
2#define _EIO_FILE_PRIVATE_H
3
4typedef struct _Eio_Job_Data Eio_Job_Data;
5
6struct _Eio_Job_Data
7{
8 Eo *object;
9 Eina_List *operations;
10};
11
12#endif
diff --git a/src/lib/eio/eio_sentry.c b/src/lib/eio/eio_sentry.c
new file mode 100644
index 0000000000..c0bf7b1d49
--- /dev/null
+++ b/src/lib/eio/eio_sentry.c
@@ -0,0 +1,166 @@
1/* EIO - EFL data type library
2 * Copyright (C) 2016 Enlightenment Developers:
3 * Lauro Moura <lauromoura@expertisesolutions.com.br>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18<