Eio
Date
2012 (created)

Table of Contents

Introduction

The Eio library is a library that implements an API for asynchronous input/output operation. Most operations are done in a separate thread to prevent lock. See Eio. Some helper to work on data received in Eio callback are also provided see Eio Reference helper API. It is also possible to work asynchronously on Eina_File with Manipulate an Eina_File asynchronously or on Eet_File with Eio asynchronous API for Eet file.. It comes with way to manipulate eXtended attribute asynchronous with Eio manipulation of eXtended attribute..

This library is cross-platform and can be compiled and used on Linux, BSD, Opensolaris and Windows (XP and CE). It is heavily based on Ecore main loop.

How to compile

Eio is a library your application links to. The procedure for this is very simple. You simply have to compile your application with the appropriate compiler flags that the pkg-config script outputs. For example:

Compiling C or C++ files into object files:

gcc -c -o main.o main.c `pkg-config --cflags eio`

Linking object files into a binary executable:

gcc -o my_application main.o `pkg-config --libs eio`

See pkgconfig

Next Steps

After you understand what Eio is and installed it on your system you should proceed understand the programming interface.

Recommended reading:

Introductory Example

//Compile with:
//gcc -o eio_file_ls eio_file_ls.c `pkg-config --cflags --libs ecore eio`
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Eio.h>
#include <Ecore.h>
static Eina_Bool
_filter_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, const char *file)
{
char *last_slash = strrchr(file, '/');
//Check if it is a hidden file
if (last_slash != NULL && strlen(last_slash) > 1 && last_slash[1] == '.')
return EINA_FALSE;
return EINA_TRUE;
}
static void
_main_cb(void *data, Eio_File *handler EINA_UNUSED, const char *file)
{
int *number_of_listed_files = (int *)data;
printf("Processing file:%s\n", file);
(*number_of_listed_files)++;
}
static void
_done_cb(void *data, Eio_File *handler EINA_UNUSED)
{
int *number_of_listed_files = (int *)data;
printf("Number of listed files:%d\n" \
"ls operation is done, quitting.\n", *number_of_listed_files);
}
static void
_error_cb(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, int error)
{
fprintf(stderr, "Something has gone wrong:%s\n", strerror(error));
}
int
main(int argc, char **argv)
{
int number_of_listed_files = 0;
if (argc < 2)
{
fprintf(stderr, "You must pass a path to execute the command.\n");
return -1;
}
eio_file_ls(argv[1], _filter_cb, _main_cb, _done_cb, _error_cb,
&number_of_listed_files);
return 0;
}

More examples can be found at Eio Examples.

ecore_main_loop_quit
void ecore_main_loop_quit(void)
Quits the main loop once all the events currently on the queue have been processed.
Definition: ecore_main.c:1308
EINA_UNUSED
#define EINA_UNUSED
Definition: eina_types.h:339
EINA_FALSE
#define EINA_FALSE
Definition: eina_types.h:533
eio_shutdown
int eio_shutdown(void)
Shutdown eio and all its submodule if possible.
Definition: eio_main.c:340
eio_init
int eio_init(void)
Initialize eio and all its required submodule.
Definition: eio_main.c:276
ecore_main_loop_begin
void ecore_main_loop_begin(void)
Runs the application main loop.
Definition: ecore_main.c:1298
EINA_TRUE
#define EINA_TRUE
Definition: eina_types.h:539
eio_file_ls
EAPI Eio_File * eio_file_ls(const char *dir, Eio_Filter_Cb filter_cb, Eio_Main_Cb main_cb, Eio_Done_Cb done_cb, Eio_Error_Cb error_cb, const void *data)
List contents of a directory without locking your app.
Definition: eio_file.c:577
Eina_Bool
unsigned char Eina_Bool
Definition: eina_types.h:527
ecore_shutdown
EAPI int ecore_shutdown(void)
Shuts down connections, signal handlers sockets etc.
Definition: ecore.c:366
Eio_File
struct _Eio_File Eio_File
Definition: Eio.h:72
ecore_init
EAPI int ecore_init(void)
Sets up connections, signal handlers, sockets etc.
Definition: ecore.c:225